Truncate date

Supported in: Batch

Returns the date rounded down to the nearest day/week/month/quarter/year.

Expression categories: Datetime

Declared arguments

  • Start - Date to truncate.
    Expression<Date | Timestamp>
  • Unit - Date unit used to truncate.
    Enum<Days, Months, Quarters, Weeks, Years>

Output type: Date

Examples

Example 1: Base case

Argument values:

  • Start: 2022-02-10T10:00:00Z
  • Unit: DAYS

Output: 2022-02-10


Example 2: Base case

Argument values:

  • Start: 2022-02-10
  • Unit: MONTHS

Output: 2022-02-01


Example 3: Base case

Argument values:

  • Start: 2022-02-10
  • Unit: QUARTERS

Output: 2022-01-01


Example 4: Base case

Argument values:

  • Start: 2022-02-10
  • Unit: YEARS

Output: 2022-01-01


Example 5: Null case

Argument values:

  • Start: null
  • Unit: YEARS

Output: null