You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[DATE_TRUNC](date-trunc.md)| Truncates a timestamp to a specified precision |`DATE_TRUNC('month', '2024-06-04')` → `2024-06-01`|
66
+
|[TIME_SLICE](time-slice.md)| Map a single date/timestamp value to a calendar-aligned interval |`TIME_SLICE('2024-06-04', 4, 'MONTH', 'START')` → `2024-05-01`|
67
+
|[TO_START_OF_DAY](to-start-of-day.md)| Returns the start of the day |`TO_START_OF_DAY('2024-06-04 12:30:45')` → `2024-06-04 00:00:00`|
68
+
|[TO_START_OF_HOUR](to-start-of-hour.md)| Returns the start of the hour |`TO_START_OF_HOUR('2024-06-04 12:30:45')` → `2024-06-04 12:00:00`|
69
+
|[TO_START_OF_MINUTE](to-start-of-minute.md)| Returns the start of the minute |`TO_START_OF_MINUTE('2024-06-04 12:30:45')` → `2024-06-04 12:30:00`|
70
+
|[TO_START_OF_MONTH](to-start-of-month.md)| Returns the start of the month |`TO_START_OF_MONTH('2024-06-04')` → `2024-06-01`|
71
+
|[TO_START_OF_QUARTER](to-start-of-quarter.md)| Returns the start of the quarter |`TO_START_OF_QUARTER('2024-06-04')` → `2024-04-01`|
72
+
|[TO_START_OF_YEAR](to-start-of-year.md)| Returns the start of the year |`TO_START_OF_YEAR('2024-06-04')` → `2024-01-01`|
73
+
|[TO_START_OF_WEEK](to-start-of-week.md)| Returns the start of the week |`TO_START_OF_WEEK('2024-06-04')` → `2024-06-03`|
73
74
74
75
## Date & Time Navigation Functions
75
76
76
-
| Function | Description | Example |
77
-
|----------|-------------|---------|
78
-
|[LAST_DAY](last-day.md)| Returns the last day of the month |`LAST_DAY('2024-06-04')` → `2024-06-30`|
79
-
|[NEXT_DAY](next-day.md)| Returns the date of the next specified day of week |`NEXT_DAY('2024-06-04', 'SUNDAY')` → `2024-06-09`|
import FunctionDescription from '@site/src/components/FunctionDescription';
5
+
6
+
<FunctionDescriptiondescription="Introduced or updated: v1.2.799"/>
7
+
8
+
TIME_SLICE is a scalar function used to map a single date/timestamp value to a fixed calendar interval (slice or bucket).
9
+
10
+
It returns the boundary (starting or ending point) of the calendar interval containing the time point, and is often used to group, aggregate and report time series data by custom calendar periods, such as summarizing by a 2-week, 3-month or 15-minute window.
|`<date_or_time_expr>`| DATE, TIME, TIMESTAMP or other date/time expression. The return type matches the input type where possible. |
21
+
|`<slice_length>`| INTEGER >= 1. The number of contiguous IntervalKind units in a slice (e.g., 2 for 2-week slices). |
22
+
|`<IntervalKind>`| One of the following (case-insensitive): YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND. |
23
+
|`<start_or_end>`| String 'START' or 'END' (case-insensitive). If omitted, defaults to 'START'. |
24
+
25
+
26
+
## Semantics
27
+
28
+
- For a given call TIME_SLICE(value, slice_length, IntervalKind, start_or_end):
29
+
- START returns the exact calendar boundary that begins the slice (inclusive).
30
+
- END returns the boundary immediately after the slice (an exclusive upper bound). Depending on the input type and system precision, END can also be interpreted as the last representable instant of the slice if you convert it to an inclusive endpoint by subtracting the smallest time unit.
0 commit comments