Skip to main content

MILLENNIUM

Returns the millennium of a given date or timestamp. The 1st millennium spans years 0001–1000, the 2nd spans 1001–2000, the 3rd spans 2001–3000, and so on.

Syntax

MILLENNIUM(<date_or_timestamp>)

Return Type

UInt8 — the millennium number starting from 1.

Examples

SELECT
MILLENNIUM('1992-02-15') AS millennium_1992,
MILLENNIUM('2025-04-16 12:34:56') AS millennium_2025;
┌───────────────────────────────────┐
│ millennium_1992 │ millennium_2025 │
├─────────────────┼─────────────────┤
23
└───────────────────────────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today