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 (starting Monday), Weeks (starting Sunday), 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: date
  • Unit: WEEKS
dateOutput
2025-01-182025-01-13
2025-01-192025-01-13
2025-01-202025-01-20
2025-01-212025-01-20
2025-01-222025-01-20
2025-01-232025-01-20
2025-01-242025-01-20
2025-01-252025-01-20
2025-01-262025-01-20
2025-01-272025-01-27

Example 5: Base case

Argument values:

  • Start: date
  • Unit: WEEKS_STARTING_SUNDAY
dateOutput
2025-01-182025-01-12
2025-01-192025-01-19
2025-01-202025-01-19
2025-01-212025-01-19
2025-01-222025-01-19
2025-01-232025-01-19
2025-01-242025-01-19
2025-01-252025-01-19
2025-01-262025-01-26
nullnull

Example 6: Base case

Argument values:

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

Output: 2022-01-01


Example 7: Null case

Argument values:

  • Start: null
  • Unit: YEARS

Output: null