Skip to main content

Date Part Functions

Date part functions extract specific components from date and timestamp values. CeloSQL provides dedicated functions for each date/time component.

YEAR

Extracts the year from a date or timestamp.

Syntax

YEAR(date_expression)

Examples

> SELECT YEAR(DATE '2024-03-15');
2024

QUARTER

Extracts the quarter (1-4) from a date or timestamp.

Syntax

QUARTER(date_expression)

Examples

> SELECT QUARTER(DATE '2024-01-01');
1

MONTH

Extracts the month (1-12) from a date or timestamp.

Syntax

MONTH(date_expression)

Examples

> SELECT MONTH(DATE '2025-12-12');
12

WEEK

Extracts the week number (1-53) from a date or timestamp.

Syntax

WEEK(date_expression)

Examples

> SELECT WEEK(DATE '2025-10-24');
43

DAYOFYEAR

Extracts the day of the year (1-366) from a date or timestamp.

Syntax

DAYOFYEAR(date_expression)

Examples

> SELECT DAYOFYEAR(DATE '1998-05-05');
125

DAYOFMONTH

Extracts the day of the month (1-31) from a date or timestamp.

Syntax

DAYOFMONTH(date_expression)

Examples

> SELECT DAYOFMONTH(DATE '1998-05-05');
5

DAYOFWEEK

Extracts the day of the week from a date or timestamp.

Syntax

DAYOFWEEK(date_expression)

Examples

> SELECT DAYOFWEEK(DATE '1998-05-05');
3

HOUR

Extracts the hour (0-23) from a timestamp.

Syntax

HOUR(timestamp_expression)

Examples

> SELECT HOUR(TIMESTAMP '1998-05-05 10:00:00');
10

MINUTE

Extracts the minute (0-59) from a timestamp.

Syntax

MINUTE(timestamp_expression)

Examples

> SELECT MINUTE(TIMESTAMP '1998-05-05 10:38:00');
38

SECOND

Extracts the second (0-59) from a timestamp.

Syntax

SECOND(timestamp_expression)

Examples

> SELECT SECOND(TIMESTAMP '1998-05-05 10:00:59');
59

Arguments

  • date_expression: A DATE, TIMESTAMP, or TIMESTAMP WITH TIME ZONE value.

Returns

A BIGINT representing the extracted component.

See Also