跳转至

Truncate date(截断日期(Truncate date))

Supported in: Batch, Faster

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

Expression categories: Datetime

Declared arguments

  • Start: Date to truncate.
    Expression\
  • Unit: Date unit used to truncate.
    Enum\

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
date Output
2025-01-18 2025-01-13
2025-01-19 2025-01-13
2025-01-20 2025-01-20
2025-01-21 2025-01-20
2025-01-22 2025-01-20
2025-01-23 2025-01-20
2025-01-24 2025-01-20
2025-01-25 2025-01-20
2025-01-26 2025-01-20
2025-01-27 2025-01-27

Example 5: Base case

Argument values:

  • Start: date
  • Unit: WEEKS_STARTING_SUNDAY
date Output
2025-01-18 2025-01-12
2025-01-19 2025-01-19
2025-01-20 2025-01-19
2025-01-21 2025-01-19
2025-01-22 2025-01-19
2025-01-23 2025-01-19
2025-01-24 2025-01-19
2025-01-25 2025-01-19
2025-01-26 2025-01-26
null null

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



中文翻译


截断日期(Truncate date)

支持模式:批处理(Batch)、快速(Faster)

将日期向下舍入到最近的日/周/月/季度/年。

表达式类别: 日期时间(Datetime)

声明的参数

  • 起始日期(Start): 需要截断的日期。
    表达式\<日期(Date)| 时间戳(Timestamp)>
  • 单位(Unit): 用于截断的日期单位。
    枚举\<天(Days)、月(Months)、季度(Quarters)、周(从周一开始)(Weeks (starting Monday))、周(从周日开始)(Weeks (starting Sunday))、年(Years)>

输出类型: 日期(Date)

示例

示例 1:基础情况

参数值:

  • 起始日期: 2022-02-10T10:00:00Z
  • 单位: DAYS

输出: 2022-02-10


示例 2:基础情况

参数值:

  • 起始日期: 2022-02-10
  • 单位: MONTHS

输出: 2022-02-01


示例 3:基础情况

参数值:

  • 起始日期: 2022-02-10
  • 单位: QUARTERS

输出: 2022-01-01


示例 4:基础情况

参数值:

  • 起始日期: date
  • 单位: WEEKS
date 输出
2025-01-18 2025-01-13
2025-01-19 2025-01-13
2025-01-20 2025-01-20
2025-01-21 2025-01-20
2025-01-22 2025-01-20
2025-01-23 2025-01-20
2025-01-24 2025-01-20
2025-01-25 2025-01-20
2025-01-26 2025-01-20
2025-01-27 2025-01-27

示例 5:基础情况

参数值:

  • 起始日期: date
  • 单位: WEEKS_STARTING_SUNDAY
date 输出
2025-01-18 2025-01-12
2025-01-19 2025-01-19
2025-01-20 2025-01-19
2025-01-21 2025-01-19
2025-01-22 2025-01-19
2025-01-23 2025-01-19
2025-01-24 2025-01-19
2025-01-25 2025-01-19
2025-01-26 2025-01-26
null null

示例 6:基础情况

参数值:

  • 起始日期: 2022-02-10
  • 单位: YEARS

输出: 2022-01-01


示例 7:空值情况

参数值:

  • 起始日期: null
  • 单位: YEARS

输出: null