HOUR

The HOUR function returns the hour as a number from 0 (12 AM) to 23 (11 PM).

Syntax

HOUR(
    datetime
)

Parameters
  • datetime: Value corresponding to a datetime variable, such as 15:35:28 or 5:16 PM, from which we want to extract the hour number.
Returned value

The HOUR function returns an integer from 0 to 23.

Additional Information

Even though the HOUR function requires a datetime type argument, it can also receive a real number (in which the integer part is considered as a reference to the date and the decimal part as a reference to the time), in general format or in any other format (of date and time or other). For this reason, the HOUR function takes both a time and a date as an argument. In the case of receiving a date as an argument, the day, month and year values are ignored, and only the hour value is extracted.

The datetime argument can be included in the function using a create date/time function, a function that returns a date/time value, as a reference to a column that contains date/time values, or by directly entering the date/time value in any of the accepted formats. In the latter case, the HOUR function will use the regional configuration and the date and time settings of the client computer in order to interpret the text from which to extract the appropriate value. In this way, the following functions (which receive the same real number as an argument with a different format), will return the same value: 11.

Hour = HOUR("10/15/2016 11:9:14")

Hour = HOUR(42658.4230787037)

Examples

The following example extracts the time from the field that contains the date and time of the sales:

HOUR function: Example of use

Related functions
Category
Date and time
Submitted by admin on Tue, 12/04/2018 - 00:04