- Determining which candidate rows are assigned to which bucket in a GROUP BY TIME operation
- Using the result in a join or to insert into a table if you assign bucket numbers to rows outside of a GROUP BY TIME operation
- The name of the database where the function is located.
Any expression evaluating to a DATE or TIMESTAMP that is used as time zero for this function. A time zone for the timestamp is optional.
- Any expression evaluating to a DATE or TIMESTAMP that is used as the timecode for this function. A time zone for the timestamp is optional.
- timebucket duration
- A time duration that can be specified using any of the units of time shown in the diagram. Abbreviations are allowed for the duration:
Time Unit Formal Form Example Shorthand Equivalents Calendar Years CAL_YEARS(4) 4cy
Calendar Months CAL_MONTHS(5) 5cm
24 hour periods starting at 00:00:00.000000 and ending at 23:59:59.999999 on the day identified by time zero.
Weeks WEEKS(3) 3w
24 hour periods starting from time zero.
Hours HOURS(4) 4h
Minutes MINUTES(23) 23m
Seconds SECONDS(33) 33s
Milliseconds MILLISECONDS(12) 12ms
Microseconds MICROSECONDS(10) 10us
- A 16-bit positive integer with a maximum value of 32,767.
The return type of this function is BIGINT.
You can reference this function in any SQL request where a system function call is valid.
Example: Use TD_TIME_BUCKET_NUMBER to Calculate a Time Bucket Number
SELECT TD_TIMECODE, TD_TIME_BUCKET_NUMBER(DATE '1900-01-01', TD_TIMECODE, CAL_YEARS(10)) FROM ts_group_by_time_tb WHERE id = 0 ORDER BY 2; TD_TIMECODE TD_TIME_BUCKET_NUMBER(1900-01-01,TD_TIMECODE,CAL_YEARS(10)) 2006-06-06 06:06:06.006002 11