Date Format Constants

The FormatDateTime function allows you to specify the format in which a date or time is displayed by choosing one of the date format constants to supply to its NamedFormat parameter:

Constant

Value

Description

vbGeneralDate

0

Display a date in short date format and a time in long time format. If present, both parts are displayed.

vbLongDate

1

Use the long date format defined in the local computer’s regional settings.

vbLongTime

3

Use the long time format defined in the local computer’s regional settings.

vbShortDate

2

Use the short date format defined in the local computer’s regional settings.

vbShortTime

4

Use the short time format defined in the local computer’s regional settings.

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.