The VBA HOUR Function

Related Functions:
VBA Minute
VBA Second

Description

The VBA Hour Function returns the hour component of a supplied time. The syntax of the function is:

Hour( Time )

VBA Hour Function Example

A simple example of the VBA Hour function is shown below:

' Extract the hour component from the time "17:56:33"
Const currTime = "17:56:33"
Dim hourNum As Integer
hourNum = Hour(currTime)

After running the above snippet of VBA code, the variable hourNum holds the value 17, which is the hour component of the supplied time "17:56:33".