prorm API Reference
    Preparing search index...

    Function dateTrunc

    • Truncate a date/timestamp expression down to the start of the given unit boundary (year/quarter/month/week/day/hour/minute/second).

      Dialect notes:

      • postgres / cockroachdb / redshift: native DATE_TRUNC('unit', expr).
      • mysql / mariadb: NO native DATE_TRUNC exists (verified) — built via DATE_FORMAT/string-concat + STR_TO_DATE workarounds.
      • mssql: uses DATETRUNC(datepart, expr), added in SQL Server 2022. For older MSSQL versions there is no native equivalent; this targets modern SQL Server.
      • oracle: TRUNC(expr, fmt). Oracle's TRUNC only truncates down to hour/minute ('HH24'/'MI'); truncating to 'second' is a no-op since DATE values already carry second precision, so expr is returned unchanged.
      • sqlite: no native function — built via strftime()/string-concat.
      • db2: no native DATE_TRUNC — built via VARCHAR_FORMAT/TIMESTAMP_FORMAT round-tripping (Db2's TO_CHAR/TO_DATE equivalents) plus DAYOFWEEK() for week truncation.
      • snowflake: native DATE_TRUNC('unit', expr).
      • clickhouse: dedicated toStartOfYear/toStartOfQuarter/toStartOfMonth/ toStartOfWeek/toStartOfDay/toStartOfHour/toStartOfMinute/ toStartOfSecond functions (genuinely different function-per-unit API, not a single parameterized function).

      Parameters

      Returns DateTimeExpression