Date problem

  • Thread starter Thread starter alvin Kuiper
  • Start date Start date
A

alvin Kuiper

Hi
I work in access english 2007, but on a danish Pc
so my date format is in danish dd-mm-yyyy

I try theis code:
strsql = "SELECT * FROM MaskinUdlejeLinje WHERE ((#" & StartDato.Value & "#
Between [startdato] And [slutdato])) "

Startdato and slutdato is a date field in my table

If StartDato.Value = 13-12-2008 then it works allright
and find my record there have startdato 12-12-2008 and slutdato 18-12-2008

But if i use 03-12-2008 then it can't find my record there have
startdato 02-12-2008 and slutdato 04-12-2008

I belive it something about date format but can't solve this problem

If i run it as a querie in access then it works, but not in my code

Can someone help her ?
 
hi Alvin,

alvin said:
I work in access english 2007, but on a danish Pc
so my date format is in danish dd-mm-yyyy
This is an Access specific problem, date literals must always be in the
American format.
I try theis code:
strsql = "SELECT * FROM MaskinUdlejeLinje WHERE ((#" & StartDato.Value & "#
Between [startdato] And [slutdato])) "
I'm using this function (place it in a standard module):

Public Function SQLDateTime(ADateTime As Date) As String

SQLDateTime = Format(ADateTime, "\#m\/d\/yyyy hh\:nn\:ss\#")

End Function

strsql = "SELECT * " & _
"FROM MaskinUdlejeLinje " & _
"WHERE " & SQLDateTime(StartDato.Value) & " " & _
"BETWEEN [startdato] AND [slutdato]"


mfG
--> stefan <--
 
Back
Top