By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,062 Members | 1,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,062 IT Pros & Developers. It's quick & easy.

Updating table with Date using SQL

P: 30
Hey all,

I'm trying to update a table using sql with todays date.

I use this,

Expand|Select|Wrap|Line Numbers
  1. Dim todaysDate As Date
  2.  
  3. todaysDate = Date
  4.  
  5. DoCmd.SetWarnings False
  6. DoCmd.RunSQL "UPDATE Followup " & _
  7.              "SET Followup.EmailSentDate = " & todaysDate & ", Followup.Completed = 'Yes'" & _
  8.              "WHERE (((Followup.ID) = " & Main.followupID2 & "))"
  9. DoCmd.SetWarnings True
Everything is working fine, but the Followup.EmailSentDate is always the time i.e. 12:00:56 not the date.
The field is a Date/Time field, but i just don't understand why it doesn't place the date there.

All help welcome,

Thanks
Jun 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: 30
Got it

Expand|Select|Wrap|Line Numbers
  1.       Dim todaysDate As Date
  2.       todaysDate = Date
  3.  
  4.       DoCmd.SetWarnings False
  5.       DoCmd.RunSQL "UPDATE Followup " & _
  6.                    "SET Followup.EmailSentDate = " & "'" & todaysDate & "'" & ", Followup.Completed = 'Yes'" & _
  7.                    "WHERE (((Followup.ID) = " & Main.followupID2 & "))"
  8.       DoCmd.SetWarnings True
Need to place " ' " before and after the date
Jun 4 '07 #2

ADezii
Expert 5K+
P: 8,638
Hey all,

I'm trying to update a table using sql with todays date.

I use this,

Expand|Select|Wrap|Line Numbers
  1. Dim todaysDate As Date
  2.  
  3. todaysDate = Date
  4.  
  5. DoCmd.SetWarnings False
  6. DoCmd.RunSQL "UPDATE Followup " & _
  7.              "SET Followup.EmailSentDate = " & todaysDate & ", Followup.Completed = 'Yes'" & _
  8.              "WHERE (((Followup.ID) = " & Main.followupID2 & "))"
  9. DoCmd.SetWarnings True
Everything is working fine, but the Followup.EmailSentDate is always the time i.e. 12:00:56 not the date.
The field is a Date/Time field, but i just don't understand why it doesn't place the date there.

All help welcome,

Thanks
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SetWarnings False
  2.  
  3. Dim MySQL As String
  4.  
  5. MySQL = "UPDATE Followup SET Followup.EmailSentDate = Date(), "
  6. MySQL = MySQL & "Followup.Completed = 'Yes' WHERE Followup.ID = " & Main.followupID2
  7.  
  8. DoCmd.SetWarnings True
Jun 5 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.