The Hour function returns an integer between 0 and 23 that is the hour of the day indicated in the parameter number.
The parameter string is any number expressed as a string that can represent a date and time from January 1, 1980 through December 31, 9999.
Example
' This example shows various uses of the Format function to format values
' using both named and user-defined formats. For the date separator (/),
' time separator (:), and AM/ PM literal, the actual formatted output
' displayed by your system depends on the locale settings on which the code
' is running. When times and dates are displayed in the development
' environment, the short time and short date formats of the code locale
' are used. When displayed by running code, the short time and short date
' formats of the system locale are used, which may differ from the code
' locale. For this example, English/United States is assumed.
' MyTime and MyDate are displayed in the development environment using
' current system short time and short date settings.
Sub Main
MyTime = "08:04:23 PM"
MyDate = "03/03/07"
MyDate = "January 27, 2007"
MsgBox Now
MsgBox MyTime
MsgBox Second( MyTime ) & " Seconds"
MsgBox Minute( MyTime ) & " Minutes"
MsgBox Hour( MyTime ) & " Hours"
MsgBox Day( MyDate ) & " Days"
MsgBox Month( MyDate ) & " Months"
MsgBox Year( MyDate ) & " Years"
' Returns current system time in the system-defined long time format.
MsgBox Format(Time, "Short Time")
MyStr = Format(Time, "Long Time")
' Returns current system date in the system-defined long date format.
MsgBox Format(Date, "Short Date")
MsgBox Format(Date, "Long Date")
' This section not yet supported
'MyStr = Format(MyTime, "h:n:s") ' Returns "17:4:23".
'MyStr = Format(MyTime, "hh:nn:ss AMPM") ' Returns "05:04:23 PM".
'MyStr = Format(MyDate, "dddd, nnn d yyyy") ' Returns "Wednesday, _
' Jan 27 2007".
' If format is not supplied, a string is returned.
MsgBox Format(23) ' Returns "23".
' User-defined formats.
MsgBox Format(5459.4, "##,##0.00") ' Returns "5,459.40".
MsgBox Format(334.9, "###0.00") ' Returns "334.90".
MsgBox Format(5, "0.00%") ' Returns "500.00%".
MsgBox Format("HELLO", "<") ' Returns "hello".
MsgBox Format("This is it", ">") ' Returns "THIS IS IT".
End Sub