Date, Date$ (functions)




Returns the current system date.


The Date$ function returns the date using the short date format. The Date function returns the date as a Date variant.

Use the Date/Date$ statements to set the system date.

The date is returned using the current short date format (defined by the operating system).

Important: The Date$ function does not properly support international formats. Use the Date function instead.


This example saves the current date to TheDate$, then changes the date and displays the result. It then changes the date back to the saved date and displays the restored date.

' When run with non-US Regional or International settings,

' the two message boxes may display different dates.

' One set of International Date Formats which shows this is:

'    Short Date Format: dd.M.yy (ex: 02.01.97 for 2 January 1997)

'    Long Date Format: ddddd, dd M, yyyy (Thursday, 02 January 1997)

Sub Main()

   ' Save the current date

   TheDate$ = Date


' Set the date to one that may confuse the library functions

   ' (month and day < 12)

   Date ="01/02/97"                      ' 1 Feb 1997

   MsgBox(Format$ (Date$, "dddddd"))    ' This may show 2 Jan

   MsgBox(Format$ (Date, "dddddd"))    ' This may show 1 Feb


   ' Restore the date

   Date = TheDate$

End Sub

See Also

CDate, CVDate (functions); Time, Time$ (functions); Date, Date$ (statements); Now (function); Format, Format$ (functions); DateSerial (function); DateValue (function).

More information