2007-11-29

Formatting Dates and Times

Formatting Dates and Times

A format string for date/time values can use one of the predefined string values shown in the following table.

StringDescription
Long DateDDisplays a date in long date format.
Short DatedDisplays a date in short date format.
Long TimeTDisplays a date in long date format.
Short TimetDisplays a date in short date format.
FDisplays the long date and long time.
fDisplays the long date and short time.
gDisplays the short date and short time.
MmDisplays the month and the day of a date.
YyFormats the date as the year and month.






Examples of applying a format string to date/time values are shown in the following table.

FormatOutput
Format(Now,"D")Thursday, November 29, 2007
Format(Now,"d")11/29/2007
Format(Now,"T")3:20:02 AM
Format(Now,"t")3:20 AM
Format(Now,"F")Thursday, November 29, 2007 3:20:02 AM
Format(Now,"f")Thursday, November 29, 2007 3:20 AM
Format(Now,"g")11/29/2007 3:20 AM
Format(Now,"m")November 29
Format(Now,"y")November, 2007

No comments:

Google Referrals