Skip to content

temporal-trunc

Truncates a timestamp value to the specified precision. For example, truncating a timestamp down to the hour returns the timestamp corresponding to start of the hour of the original timestamp’s hour.

trunc( <timestamp_expr>, <unit> )

This argument must evaluate to a timestamp.

This argument must be one of the strings listed below:

  • hour
  • minute
  • second
  • millisecond
  • microsecond
  • nanosecond

The returned value is of timestamp type.

Truncate a timestamp down to the minute:

SELECT now(), trunc(now(), 'minute');
+-----------------------------+------------------------+
| now() | trunc(now(), 'minute') |
+-----------------------------+------------------------+
| 2025-01-24T08:13:39.192704Z | 2025-01-24T08:13:00Z |
+-----------------------------+------------------------+
ScopeDB Logo ScopeDB
© 2025 ScopeDB. All rights reserved.