Skip to main content

TO_YEARS

Introduced or updated: v1.2.677

Converts a specified number of years into an Interval type.

  • Accepts positive integers, zero, and negative integers as input.

Syntax

TO_YEARS(<years>)

Return Type

Interval (represented in years).

Examples

SELECT TO_YEARS(2), TO_YEARS(0), TO_YEARS((- 2));

┌───────────────────────────────────────────┐
│ to_years(2) │ to_years(0) │ to_years(- 2)
├─────────────┼─────────────┼───────────────┤
2 years │ 00:00:00-2 years │
└───────────────────────────────────────────┘
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