HOUR

The function HOUR returns the value of the hour in a Time or DateTime.

This function takes input in the form of either a Time or a DateTime. It returns a Number: the value of the hour in the given Time or a DateTime.

Declaration

HOUR(datetime) -> hour
HOUR(time) -> hour

Parameters

datetime (type: DateTime)

Any DateTime. This is what describes the hour value that the HOUR function will return.

time (type: Time)

Any Time. This is what describes the hour value that the HOUR function will return.

Return Values

hour (type: number)

The hour value from the given Time or DateTime.

Examples

Assume the first example has access to the following DateTime value:

example_date_and_time = {  
 "date": {  
  "day": 1,  
  "month": 4,  
  "year": 2021  
 },  
 "time": {  
  "hour": 16,  
  "minute": 14,  
  "second": 38,  
  "millisecond": 0  
 },  
 "timeZone": "UTC"  
}

The following example takes the time described in example_date_and_time and outputs the number of hours described:

HOUR(example_date_and_time) = 16

The above example demonstrates how the HOUR function behaves when given a DateTime as input. In order to further establish how the HOUR function behaves when given a Time as input, assume the last example has access to the following Time value:

example_time = {  
 "hour": 16,  
 "minute": 14,  
 "second": 38,  
 "millisecond": 0  
}

The following example takes the time described in example_time and outputs the number of hours described:

HOUR(example_time) = 16

Last updated