v.24.4Improvement

Added nano, micro, and millisecond units to date_trunc

Added nano-, micro-, milliseconds unit for date_trunc. #62335 (Misz606).
Added support for nano-, micro-, and milliseconds units in the date_trunc function.

Why it matters

This feature enhances the date_trunc function by allowing users to truncate dates to finer time units (nanoseconds, microseconds, and milliseconds). It solves the limitation of the previous versions where only coarser units were supported, enabling more precise time-based data manipulation and aggregation.

How to use it

Use the date_trunc function with the new time units by specifying the unit parameter as 'nano', 'micro', or 'millisecond'. For example:

SELECT date_trunc('microsecond', some_datetime_column) FROM table