I created a module that returns every date in a range. When I use the msgbox feature during runtime to show the result, it appears as a date - but when I store the result in a table containing a date/time field, it appears as 12:01am, 12:03am, etc.
I've added CDate everywhere I could and still get this result. I set the format to short date, long date, etc...
Here's the function:
Public Function SerialDate()
Dim StartDate As Date
Dim EndDate As Date
Dim MyDate As Date
StartDate = CDate(#1/1/2007#)
EndDate = CDate(#1/30/2007#)
MyDate = StartDate
While MyDate %26lt;= EndDate
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO TempDate ( SerialDate ) Select " %26amp; Format(CDate(MyDate), "Short Date") %26amp; " As Expr1;"
MyDate = CDate(DateAdd("d", 1, MyDate))
Wend
End Function
Why is my date result stored in time format in MS Access?
did you set the format on the table / field properties?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment