how to generate today's date (genera format) and use it in update query (1 Viewer)

MilaK

Registered User.
Local time
Today, 02:29
Joined
Feb 9, 2015
Messages
285
Hello,

I would like to generate today's date and time and use it in update query. When I try

Dim todaysDate As Date
todaysDate = Date
Debug.Print todaysDate

it returns 9/14/2017 but I would like to return date and time and also use it in update query. Do I need any special formatting to get it to update a table where that field is "General Date"?

Thanks,

Mila
 

Minty

AWF VIP
Local time
Today, 10:29
Joined
Jul 26, 2013
Messages
10,371
Simple - instead of Date() use Now() - All dates in access are stored as DateTimes. Just that a date has the time set to 00:00:00
 

MilaK

Registered User.
Local time
Today, 02:29
Joined
Feb 9, 2015
Messages
285
Which is correct usage of Now() in a query:

Code:
'
Dim todaysDate As Date
todaysDate = Now

SQL4 = "UPDATE tbl_Projects SET tbl_Projects.second_review_completed_date = #" & todaysDate & "#"
  
or      
        SQL4 = "UPDATE tbl_Projects SET tbl_Projects.second_review_completed_date = " & todaysDate & ""

Thanks,

Mila
 

Minty

AWF VIP
Local time
Today, 10:29
Joined
Jul 26, 2013
Messages
10,371
Well you can use Now() directly from what I remember;

Code:
SQL4 = "UPDATE tbl_Projects SET tbl_Projects.second_review_completed_date = Now()"
 

Users who are viewing this thread

Top Bottom