Access: Hour Function

In Access, the Hour function returns a number between 0 and 23, inclusive, that represents the hour of the day corresponding to the time provided as an argument.

The syntax for the Hour function is:

Hour ( time )

The required time argument is any numeric or string expression, that can represent a time. If number is Null, this function returns a Null.

Examples

Hour (#4:37:12 PM#)       returns 16 
Hour (#11:24:12 AM#)      returns 11

VBA Code

Dim MyHour As Integer 
MyHour = Hour(#3:45:12 PM#)

This example uses the Hour function to obtain the hour from a specified time. Now the MyHour variable would contain the value of 15.

SQL query

You can also use the Hour function in a query.

SELECT Hour(#10:37:12 PM#) AS Expr1 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.