Skip to content

get_hour_from_timestamp

Syntax

get_hour_from_timestamp(timestamp)

Parameters

<timestamp>
An expression representing a timestamp, formatted as either YYYYMMDDHH or YYYYMMDD.

Returns

The hour value (an integer) of the given timestamp.

Description

This action extracts and returns the hour defined by a given timestamp. The timestamp must be formatted as either YYYYMMDDHH or YYYYMMDD, where YYYY is a four-digit year, MM is a two-digit month, DD is a two-digit day, and HH is a two-digit hour.

A timestamp that exceeds the 10-character format will return the last two digits. That is, get_day_from_timestamp(20205060787654321) returns \(21\).

A malformed timestamp that does not represent an actual date will not raise an error.

Examples

The following returns \(12\) since this timestamp represents January 2, 2021 at 12 noon.

get_hour_from_timestamp(2021010212)

See Also