跳转到内容

将日期或带时间的日期(timestamp/datetime)向下取整到当月第一天。 返回日期。

func.to_start_of_month(<expr>)
func.to_start_of_month('2023-11-12 09:38:18.165575')
┌────────────────────────────────────────────────────────────────┐
│ func.to_start_of_month('2023-11-12 09:38:18.165575') │
│ Date │
├────────────────────────────────────────────────────────────────┤
│ 2023-11-01 │
└────────────────────────────────────────────────────────────────┘
TO_START_OF_MONTH(<expr>)
参数 说明
<expr> 日期/时间戳

DATE,以“YYYY-MM-DD”格式返回日期。

SELECT
to_start_of_month('2023-11-12 09:38:18.165575')
┌─────────────────────────────────────────────────┐
│ to_start_of_month('2023-11-12 09:38:18.165575') │
│ Date │
├─────────────────────────────────────────────────┤
│ 2023-11-01 │
└─────────────────────────────────────────────────┘