v.19.3New Features

Added Function Tostartofinterval

Added function toStartOfInterval. #4304 (Vitaly Baranov)
Added the function toStartOfInterval for rounding timestamps or dates down to the start of a specified interval.

Why it matters

This feature solves the problem of aligning timestamps or dates to uniform intervals, simplifying time-based grouping, aggregation, and analysis in time-series data. It provides a convenient way to normalize datetime values to the start boundary of customizable intervals.

How to use it

Use the toStartOfInterval function by passing a datetime or date value along with an interval specification to round the datetime down to the nearest interval start. For example:
SELECT toStartOfInterval(datetime_column, INTERVAL 15 minute) FROM table;