FormatDateTime
Formats a date/time in the form of a string in a user-defined format.
Syntax
FormatDateTime(format, dateTime)
format = string specifying the format to use (see below)
dateTime = the date/time that you want to format
dateTime = the date/time that you want to format
Remarks
The format string can contain the following specifiers:
| Specifier | Display |
|---|---|
| d | Displays the day number without a zero prefix (from 1 to 31). |
| dd | Displays the day number with a zero prefix (from 01 to 31). |
| ddd | Displays the abbreviated day (Sun to Sat). |
| dddd | Displays the whole day (Sunday to Saturday). |
| m | Displays the month number without a zero prefix (from 1 to 12). |
| mm | Displays the month number with a zero prefix (from 01 to 12). |
| mmm | Displays the abbreviated month (Jan to Dec). |
| mmmm | Displays the whole month (January to December). |
| yy | Displays the two-digit year number (00 to 99). |
| yyyy | Displays the four-digit year number (0000-9999). |
| h | Displays the hour on the 24-hour clock without a zero prefix (0 to 23). |
| hh | Displays the hour on the 24-hour clock with a zero prefix (00 to 23). |
| n | Displays the minutes without a zero prefix (0 to 59). |
| nn | Displays the minutes with a zero prefix (00 to 59). |
| s | Displays the seconds without a zero prefix (0 to 59). |
| ss | Displays the seconds with a zero prefix (00 to 59). |
| z | Displays the milliseconds without a zero prefix (0 to 999). |
| zzz | Displays the milliseconds with a zero prefix (000 to 999). |
Note: when 'mm' or 'm' are preceded by an hour specifier, they are interpreted as 'nn' and 'n' respectively, this allows 'hh:mm' for instance to be accepted as 'hh:nn' would be.
Example
FormatDateTime('yyyy-mm-dd', Now()) = '2010-01-12' on January 12, 2010FormatDateTime('dddd h:nn', Now()) = 'Friday 9:30' at 9:30 am on October 2, 2009