Access for Microsoft 365 Access 2021 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007 More…Less
Returns a Variant (Date) specifying the current date and time according your computer’s system date and time.
Syntax
Now
Query examples
|
|
SELECT Now() AS Expr1 FROM ProductSales GROUP BY Now(); |
Returns the current system «Date and Time» in the default system Time format and displays in the column Expr1. |
SELECT Now() AS CurrentDateandTime FROM ProductSales GROUP BY Now(); |
Returns the current system «Date and Time» in the default system Time format and displays in the column CurrentDateandTime. |
VBA example
Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.
This example uses the Now function to return the current system date and time.
Dim Today
Today = Now ' Assign current system date and time.
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
Access for Microsoft 365 Access 2021 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007 More…Less
Returns a Variant (Date) specifying the current date and time according your computer’s system date and time.
Syntax
Now
Query examples
|
|
SELECT Now() AS Expr1 FROM ProductSales GROUP BY Now(); |
Returns the current system «Date and Time» in the default system Time format and displays in the column Expr1. |
SELECT Now() AS CurrentDateandTime FROM ProductSales GROUP BY Now(); |
Returns the current system «Date and Time» in the default system Time format and displays in the column CurrentDateandTime. |
VBA example
Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.
This example uses the Now function to return the current system date and time.
Dim Today
Today = Now ' Assign current system date and time.
Need more help?
Now function
Returns a Variant (Date) specifying the current date and time according your computer’s system date and time.
Syntax
Now
Query examples
Expression |
Results |
---|---|
SELECT Now() AS Expr1 FROM ProductSales GROUP BY Now(); |
Returns the current system «Date and Time» in the default system Time format and displays in the column Expr1. |
SELECT Now() AS CurrentDateandTime FROM ProductSales GROUP BY Now(); |
Returns the current system «Date and Time» in the default system Time format and displays in the column CurrentDateandTime. |
VBA example
Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.
This example uses the Now function to return the current system date and time.
Dim Today
Today = Now ' Assign current system date and time.
Date and Now
<source lang="vb">
Sub dateFunctions()
Debug.Print "The present date and time is: " & Now Debug.Print "Today"s date is: " & Date
End Sub
</source>
Now returns a Variant/Date containing the current date and time according to your computer
<source lang="vb">
Sub dateDemo10()
Debug.Print Now
End Sub
</source>
Use Now to retrieve current Date and Time
<source lang="vb">
Private Sub myTime()
Dim time As Date Dim theHour As Integer Dim theDayOfTheWeek As Integer time = Now theHour = Hour(time) theDayOfTheWeek = Weekday(time) If (theHour > 8) And (theHour < 17) Then If (theDayOfTheWeek > 0) And (theDayOfTheWeek < 6) Then MsgBox ("You should be at work!") Else MsgBox ("I love weekends") End If Else MsgBox ("You should not be at work!") End If
End Sub
</source>
Eric
-
#1
I have a an option button with a macro that sets the
current date and time with a NOW() function. Problem is, I
have several of these buttons and when one is activated
all the dates and times are updated.
How do I Freeze the dates?
I was think about writing an IF formula that checks to see
if the cell has data before writing the NOW() function,
but I don’t know how to write a logical expression that
does nothing if the cell has data.
(IF B27 is empty, NOW(),do nothing-not even 0)How do you
express that?
Guess that’s two questions. Please help.
Advertisements
Gilles Desjardins
-
#2
Eric if you want a fix date Ctrl + ; Your date shall never change
Biff
-
#3
Hi Eric,
Here’s something you might try. In your macro right after
the call for the NOW function, add some code to do a
copy>paste special>values on the cell where the date/time
displays. Sorry I can’t provide any code other than is
generated by the recorder.
As far as the IF function, it will always ‘do something’.
Even if you were to write it as:
=IF(ISBLANK(B27),NOW()))
By default would return FALSE if B27 <> blank.
Biff
Eric
-
#4
Thanks Biff. Just had another thought: suppose i would set
one of the actions as something benign like «set text to
black», like it is anyway. Can you think of any other ways
to get around the fascist «IF» logic?
Advertisements
Biff
-
#5
As in setting a conditional format?
——Original Message——
Thanks Biff. Just had another thought: suppose i would set
one of the actions as something benign like «set text to
black», like it is anyway. Can you think of any other ways
to get around the fascist «IF» logic?
.
Want to reply to this thread or ask your own question?
You’ll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.
Ask a Question