Hour Function Description
The VBA Hour function returns the hour for the provided time (Date variable). Values range from 0 to 23.
VBA Hour Syntax
The syntax for the Hour function in VBA is:
Hour( time )
Parameters
time
The time (Date) value for which the hours are to be returned. This can be a Date variable or string expressing date/time e.g. “20:10”.
Example Usage
The Hour function can be used in VBA code. Let’s look at some VBA Hour function examples:
Hour "20:10" 'Result: 20 Hour #8:20:00 PM# 'Result: 20 Dim d as Date d = #9:02:00 PM# Debug.Print Hour(d) 'Result: 9