HOUR

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns the hour field from a timestamp or interval. This function is equivalent to EXTRACT(HOUR FROM ...).

Syntax 

1hour(<timestamp>)
1hour(<interval>)

Arguments 

Required 

  • <timestamp>: The timestamp to extract the hour from.
  • <interval>: The interval to extract the hour from.

Returns 

Returns the hour as an integer.

Examples 

Extract the Hour from a Timestamp 

Get the hour of the day from a timestamp.

1SELECT hour(timestamp '2001-02-16 20:38:40') AS result;

Returns 20.

Extract the Hour from an Interval 

Get the hour component from an interval.

1SELECT hour(interval '121 minutes') AS result;

Returns 2.

Related Documentation 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!