Date, Date$ Functions

See Also41PKIN9              Example1CC40US>Low

Returns the current system date.




Date returns a Variant8PHEAW3 of VarType7A68ZTZ 7 (Date) containing a date stored internally as a Double.

Date$ returns a 10-character string of the form mm-dd-yyyy, where mm is the month (01-12), dd is the day (01-31), and yyyy is the year (1980-2099).

The return value of the Date$ function is equivalent to:



To set the system date, use the Date[$] statement.

See Also

CVDate Function3E784K

Date, Date$ Statements3E3X9R

Format, Format$ Functions1EQ2BPO

Now FunctionLANNOW

Time, Time$ FunctionsQ3GPPU

Time, Time$, StatementsQ3GPQ7

Date, Date$ Functions Example

The example uses the Date function to provide the default date for the input box when prompting the user for a new date. To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.


Sub Form_Click ()

   Dim Default, Msg, NewDate             ' Declare variables.

   Msg = "Enter a new date in the form mm-dd-yyyy"

   Default = Date                        ' Current date.

   NewDate = InputBox(Msg, "", Default)  ' Get user input.

   If Len(NewDate) > 0 Then              ' Check if valid.

      Date = NewDate                     ' Set date.

      Msg = "System date set to "

      Msg = Msg & Format(DateValue(NewDate), "dddd, mmmm d, yyyy")


      Msg = "You did not enter a valid date."

   End If

   MsgBox Msg                            ' Display message.

End Sub