SQL Date problem

Cassio

Well-known member
Joined
Nov 30, 2002
Messages
276
Location
Rio de Janeiro
Here in Brazil we use the format dd-mm-yyyy and my windows is already configured that way.
When I use SQL Server 2000 Enterprise Manager to insert data, the date field format is also dd-mm-yyyy. But when I try to input data through VB.NET it only accepts the format mm-dd-yyyy.

Code:
        strSQL = "INSERT Compras VALUES (" & CType(cmbProdutos.SelectedItem, ListItems).ID & _
          "," & Int(txtQuantidade.Text) & "," & Int(txtUnidade.Text) & _
          "," & CInt(txtTotal.Text) & "," & CType(cmbFornecedores.SelectedItem, ListItems).ID & _
          "," & Date1 & ")"

It only works when the Date1 is like mm-dd-yyyy. Very strange.
 
This is a common issue when communicating between different systems. The best way to avoid it is to specify the date in "d-mmm-yyyy" format. This way, the day and month parts cannot get confused.
 
I use "yyyy-MM-dd" format. In this case, you need to format again your date after retrieving from database from mm/dd/yyyy to dd/mm/yyyy

Our country got the same date format with you, so we need some date functions to solve this problem
 
Back
Top