DATE()

Returns the current system date (Date).


REMARKS
* If you want the current time, then you should use the TIME function.
* To set the system date, use the DATE statement.
* The default format is "dd/mm/yyyy" (or "mm/dd/yyyy" in the US).
* When this is used in the VBA Editor the brackets are automatically removed.
* You can use the DATEADD function to return the date with a specified time interval added.
* You can use the DATEDIFF function to return the number of a given time interval between two specified dates.
* You can use the DATEPART function to return the specified part of a given date.
* You can use the DATESERIAL function to return a date given a year, month and day.
* You can use the DATEVALUE function to return a date given a string representation of a date.
* You can use the DATE$ function to return a String data type instead of a Variant/String data type.
* This function can be prefixed with "VBA."
* For the Microsoft documentation refer to docs.microsoft.com

Debug.Print Date()                                           '= volatile  
Debug.Print Format(Date(),"dd mmm yyyy hh:mm:ss") '= "21 Jul 2020 00:00:00"
Debug.Print Format(Date() + Time(),"dd mmm yyyy hh:mm:ss") '= "21 Jul 2020 12:15:59"

Dim lSerial As Long
lSerial = Date()
Debug.Print lSerial '= 44033

Dim sDate As String
sDate = Date()
Debug.Print sDate '= 21/07/2020

Dim dtDate As Date
dtDate = Date()
Debug.Print dtDate '= 21/07/2020

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top