Hour Function (Visual Basic)
Returns an Integer value from 0 through 23 that represents the hour of the day.
Public Function Hour(ByVal TimeValue As DateTime) As Integer
Parameters
- TimeValue
Required. Date value from which you want to extract the hour.
Remarks
You can also obtain the hour of the day by calling DatePart and specifying DateInterval.Hour for the Interval argument.
Example
This example uses the Hour function to obtain the hour from a specified time. In the development environment, the time literal is displayed in short time format based on the locale settings of your code.
Dim someTime As Date
Dim someHour As Integer
someTime = #4:35:17 PM#
someHour = Hour(someTime)
' someHour now contains 16.
Requirements
Namespace: Microsoft.VisualBasic
Module: DateAndTime
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
See Also
Reference
Second Function (Visual Basic)