Date$()

Syntax

Date$([SerialNumber])

Remarks

Returns a date corresponding to SerialNumber, a decimal representation of the date, time, or both. If SerialNumber is omitted, Date$() returns today's date. For information about serial numbers, see DateSerial().

The date format is determined by the "DateFormat=" line in the [Microsoft Word] section of WINWORD6.INI (Windows 3.x), Word Settings (6) (Macintosh), or the registry (Windows 95 and Windows NT). (In Windows 3.x, if there is no "DateFormat=" line, Date$() uses the "sShortDate" setting in the [intl] section of WIN.INI.) You can use SetPrivateProfileString to change the current date format.

Example

This Windows example displays the current date in a message box, in the form MMMM d, yyyy (which produces a date string such as "January 1, 1994"). The first instruction saves the original date format so that it may be restored in the last instruction. On the Macintosh, substitute "Word Settings (6)" for "WINWORD6.INI."


OriginalFormat$ = GetPrivateProfileString$("Microsoft Word", \
    "DateFormat", "WINWORD6.INI")
SetPrivateProfileString "Microsoft Word", "DateFormat", \
    "MMMM d, yyyy", "WINWORD6.INI"
MsgBox "Today is " + Date$() + "."
SetPrivateProfileString "Microsoft Word", "DateFormat", \
    OriginalFormat$, "WINWORD6.INI"

See Also

DateSerial(), DateValue(), Day(), GetPrivateProfileString$(), Month(), Now(), SetPrivateProfileString, Time$(), Today(), Year()