MyNeckHurts
Programmer
I'm running a function that should pass dates to a table. In the following example the variables debug as MyDate1 = #12/1/2004# and MyDate2 = #12/31/2004#. When they load into the table they both load as 12/30/1899. Does anyone know what's going on here?
Public Function FetchDate()
' Function to be used to pass dates to a table for a pass thru query to call the first and
' last day of the prior month.
Dim MyDate1
Dim Mydate2
DoCmd.SetWarnings False
DoCmd.OpenQuery "Delete_Dates"
MyDate1 = Now() - Day(Now()) - (Day(Now() - Day(Now())) - 1)
MyDate1 = Format$([MyDate1], "Short Date")
Mydate2 = Now() - Day(Now())
Mydate2 = Format$([Mydate2], "Short Date")
DoCmd.RunSQL "INSERT INTO FetchDateTable (FetchStartDate, FetchEndDate) VALUES (" & MyDate1 & "," & Mydate2 & ");"
End Function
Public Function FetchDate()
' Function to be used to pass dates to a table for a pass thru query to call the first and
' last day of the prior month.
Dim MyDate1
Dim Mydate2
DoCmd.SetWarnings False
DoCmd.OpenQuery "Delete_Dates"
MyDate1 = Now() - Day(Now()) - (Day(Now() - Day(Now())) - 1)
MyDate1 = Format$([MyDate1], "Short Date")
Mydate2 = Now() - Day(Now())
Mydate2 = Format$([Mydate2], "Short Date")
DoCmd.RunSQL "INSERT INTO FetchDateTable (FetchStartDate, FetchEndDate) VALUES (" & MyDate1 & "," & Mydate2 & ");"
End Function