Truncate the date to the specified date part, e.g.”month”.

Usage

DateTrunc(precision, date, [timezone])

precision (required) Smallest date part to preserve, chosen from “year”, "quarter", “month”, “week”, “day”, “hour”, “minute”, and “second”.

date (required) Date to be truncated.

timezone (optional) Name of IANA timezone to get the date part at, e.g.”America/Los_Angeles”. When calculating a timezone, input dates are treated as UTC. Note: The output returned will be presented in the organization timezone. This may cause days, months, or years to appear offset if the specified timezone is ahead of the organization timezone. If you want to see the output presented in the specified timezone, you can apply ConvertTimezone to it.

Example

DateTrunc("hour", Date("1980-05-22 8:45:30"))
  • Returns 1980-05-22 8:00:00 discarding the “minute” and”second” components of the date.
DateTrunc("day", Date("1980-05-22 8:45:30"))
  • Returns 1980-05-22 00:00:00 discarding the time components of the date.