Description
The FormatDateTime() function formats and returns a valid date or time expression.
This function has the form:
FormatDateTime(date,format)
Parameter | Description |
---|---|
date | (required) Any valid date expression (like Date() or Now()) |
format |
Optional. A value that specifies the date/time format to use. Can take the following values:
|
Examples
Display a date in different formats:
The following example shows the basic use of this function:
d = CDate("2010-02-16 13:45")
Msgbox(FormatDateTime(d))
Msgbox(FormatDateTime(d,1))
Msgbox(FormatDateTime(d,2))
Msgbox(FormatDateTime(d,3))
Msgbox(FormatDateTime(d,4))
This produces the following result (each line in a separate pop-up message box):
2/16/2010 1:45:00 PM
Tuesday, February 16, 2010
2/16/2010
1:45:00 PM
13:45
Miscellaneous Information
Supported in Version: | 2.0 |
---|