Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date not updating correctly

Status
Not open for further replies.

tractorvix

Technical User
Jun 29, 2004
122
0
0
GB
Hey Y'all!

I've set up a sub as below:

Private Sub UpdateQRMMaster(Updatedate As Date)
DoCmd.RunSQL "INSERT INTO QRM_MASTER ( Product, UpdateDate, Mat_Date, Bal ) " & _
"SELECT temp.Product, " & Updatedate & " AS UpdateDate, temp.Mat_Date, temp.Bal " & _
"FROM temp;"

End Sub

Variable updatedate is based on user input(tabledate)

Updatedate = DateSerial(Right(tabledate, 2), Mid(tabledate, 3, 2), Left(tabledate, 2))

so for example tabledate = 020708 for 2 June 2008 - this convention is used as I'm importing from daily excel reports which have this naming convention.

soooo....
have stepped through and in my locals window Updatedate = #02/07/08# with type as variant/date

however, when it is populated into the table the field records 30/12/1899

the field data type is set to date/time with format as short date.

Can someone please tell me what I'm doing wrong?

Thanks
 
It is best to use unambiguous dates:

& Format(Updatedate,"yyyy-mm-dd") &
 
SELECT temp.Product, [!]#[/!]" & Updatedate & "[!]#[/!] AS UpdateDate, temp.Mat_Date, temp.Bal " & _

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top