hour

datetime

Extracts the hour from a timestamp

Syntax

hour(date)

Parameters

date (timestamp)

The timestamp value to extract the hour from

Returns

number

The hour in 24-hour format (0-23)

Examples

Input:
hour("2024-03-15 14:30:00")
Output:
14
Get the current hour
Input:
hour(now())
Output:
10
Extract hour from a timestamp field
Input:
.timestamp | hour
Output:
9

The hour() function extracts the hour component from a timestamp value, returning a number from 0 to 23 in 24-hour format.

Usage

Use hour() to analyze hourly patterns, filter data by business hours, or group events by time of day.