The VBA Hour function returns an integer that corresponds to the time of the specified date or time.
Hour(date_hour)
Using the Hour function to get the appropriate time information:
Sub HourExample1()
myHour = #6:36:45PM#
MsgBox Hour(myHour) 'Returns: 18
End Sub
Or by date and time (for the same result):
Sub HourExample2()
myDate = #10/31/2020 6:36:45 PM#
MsgBox Hour(myDate) 'Returns: 18
End Sub
This function also accepts dates and times in text format:
Sub HourExample3()
myDate = "10/31/2020 18:36:45"
MsgBox Hour(myDate) 'Returns: 18
End Sub