跳到主要内容

Interval Functions

This section provides reference information for the interval functions in Databend. Interval functions allow you to create interval values of various time units for use in date and time calculations.

Time Unit Conversion Functions

Day-based Intervals

FunctionDescriptionExample
TO_DAYSConverts a number to an interval of daysTO_DAYS(2)2 days
TO_WEEKSConverts a number to an interval of weeksTO_WEEKS(3)21 days
TO_MONTHSConverts a number to an interval of monthsTO_MONTHS(2)2 months
TO_YEARSConverts a number to an interval of yearsTO_YEARS(1)1 year

Hour-based Intervals

FunctionDescriptionExample
TO_HOURSConverts a number to an interval of hoursTO_HOURS(5)5:00:00
TO_MINUTESConverts a number to an interval of minutesTO_MINUTES(90)1:30:00
TO_SECONDSConverts a number to an interval of secondsTO_SECONDS(3600)1:00:00
EPOCHAlias for TO_SECONDSEPOCH(60)00:01:00

Smaller Time Units

FunctionDescriptionExample
TO_MILLISECONDSConverts a number to an interval of millisecondsTO_MILLISECONDS(2000)00:00:02
TO_MICROSECONDSConverts a number to an interval of microsecondsTO_MICROSECONDS(2000000)00:00:02

Larger Time Units

FunctionDescriptionExample
TO_DECADESConverts a number to an interval of decadesTO_DECADES(2)20 years
TO_CENTRIESConverts a number to an interval of centuriesTO_CENTRIES(1)100 years
TO_MILLENNIAConverts a number to an interval of millenniaTO_MILLENNIA(1)1000 years
开始使用 Databend Cloud
低成本
快速分析
多种数据源
弹性扩展
注册