The following table lists examples of expressions that use the Format function to convert date and time values to a format you specify.
You can use these expressions in calculated controls (calculated control: A control that is used on a form, report, or data access page to display the result of an expression. The result is recalculated each time there is a change in any of the values on which the expression is based.) on forms, reports, and data access pages (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.).
Tip
In Access 2010, the Expression Builder has IntelliSense, so you can see what arguments your expression requires.
Watch a video or try Office 2010.
| Expression |
Description |
| = Format(Now(), "hh:mm AMPM") |
If the current time is 5:04:23 in the afternoon, the expression returns 05:04 PM. |
| = Format(Now(), "Long Time") |
Returns current time in the system-defined long time format. |
| = Format(Now(), "h:m:s") |
If the current time is 8:04:23, the expression returns 8:4:23. |
| = Format(Date(), "dddd, mmm d yyyy") |
If the current date is 11/14/2003, the expression returns "Friday, Nov 14 2003". |
You can use these expressions in a calculated field in a query.
| Expression |
Description |
| TimeStamp: Format(Now(), "h:m:s") |
In the TimeStamp field, displays the time as 10:50:7, if the current time is 10:50:07. |
| DayAndDate= Format(Date(), "dddd, mmm d yyyy") |
Sets the DayAndDate field to "Tuesday, Dec 2 2003" if the current date is 12/02/2003. |