DATE - Function

DATE()

Returns the current system date (Variant / Date).


REMARKS
* The default format is "dd/mm/yyyy" (or "mm/dd/yyyy" in the US).
* The brackets are automatically removed when you use this function without the (VBA.) prefix.
* This function should be prefixed with "VBA." to make the code easier to understand.
* You can use the CDATE function to return the expression converted to a date data type.
* You can use the DATE Statement to set the current system date.
* You can use the DATE$ function to return a String data type instead of a Variant data type.
* You can use the DATEADD 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 the date given a year, month and day.
* You can use the DATEVALUE function to return the date given a string representation of a date.
* You can use the DAY function to return the day from a given date.
* You can use the FORMAT function to return a text string of a date in a particular format.
* You can use the ISDATE function to return the value True or False depending if the expression is a date.
* You can use the MONTH function to return the month from a given date.
* You can use the NOW function to return the current system date and time.
* You can use the TIME function to return the current system time.
* You can use the YEAR function to return the year from a given date.
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print VBA.Date                                                '= volatile  
Debug.Print VBA.Date() '= volatile
Debug.Print VBA.Format(VBA.Date(), "dd mmm yyyy hh:mm:ss") '= "18 Feb 2024 00:00:00"
Debug.Print VBA.Format(VBA.Date() + Time(), "dd mmm yyyy hh:mm:ss") '= "18 Feb 2024 12:15:59"

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

Dim sDate As String
sDate = VBA.Date()
Debug.Print sDate '= 18/02/2024

Dim dtDate As Date
dtDate = VBA.Date()
Debug.Print dtDate '= 18/02/2024

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