date filed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
when i insert value (type date) into filed (type date) i get wrong data:
example:
strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Me.Payment_Date & ")"

even when i use :
CDate(Me.Payment_Date)
or
Me.Payment_Date : date
i get: 00:06:27
thanks.
 
SIN said:
hi,
when i insert value (type date) into filed (type date) i get wrong
data: example:
strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Me.Payment_Date & ")"

even when i use :
CDate(Me.Payment_Date)
or
Me.Payment_Date : date
i get: 00:06:27
thanks.

Date literals need to be delimited with #.

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (#" & Me.Payment_Date & "#)"
 
Rick Brandt said:
Date literals need to be delimited with #.

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (#" & Me.Payment_Date & "#)"

In addition, if you're using dd/mm/yyyy as your Short Date format (or
others), you'll need to ensure that the date is formatted in such as way
that Access will recognize it correctly.

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Format(Me.Payment_Date, "\#yyyy\-mm\-dd\#")
& ")"

or

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Format(Me.Payment_Date, "\#mm\/dd\/yyyy\#")
& ")"
 
Thanks

Douglas J. Steele said:
In addition, if you're using dd/mm/yyyy as your Short Date format (or
others), you'll need to ensure that the date is formatted in such as way
that Access will recognize it correctly.

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Format(Me.Payment_Date, "\#yyyy\-mm\-dd\#")
& ")"

or

strSQL = "insert into invoice (Payment_Date)"
strSQL = strSQL & " values (" & Format(Me.Payment_Date, "\#mm\/dd\/yyyy\#")
& ")"
 
Back
Top