TIME - Function

TIME()

Returns the current system time (Date).


REMARKS
* The brackets are NOT automatically removed when you this function without the (VBA.) prefix (unlike the DATE function).
* This function should be prefixed with "VBA." to make the code easier to understand.
* You can use the DATE function to return the current system date.
* You can use the HOUR function to return the hour from a time.
* You can use the MINUTE function to return the minutes from a time.
* You can use the NOW function to return the current system date and time.
* You can use the SECOND function to return the seconds from a time.
* You can use the TIME Statement statement to set the current system time.
* You can use the TIME$ function to return a String data type instead of a Variant data type.
* You can use the TIMER function to return the number of seconds elapsed since midnight.
* You can use the TIMESERIAL function to return the time for a specific hour, minute and second.
* You can use the TIMEVALUE function to return the time given a string representation.
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print Time          '= volatile  
Debug.Print Time() '= volatile
Debug.Print VBA.Time() '= volatile
Debug.Print VBA.Time() '= "12:49:31"

Dim sngSerial As Single
sngSerial = VBA.Time()
Debug.Print sngSerial '= 0.5340278

Dim sTime As String
sTime = VBA.Time()
Debug.Print sTime '= "12:49:31"

Dim dtTime As Date
dtTime = VBA.Time()
Debug.Print dtTime '= "12:49:31"

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