sql查询月天数之和,函数相加
时间:2022-03-15 07:37
获取当月总天数+上(几个月)月天数之和
SELECT
(
DATEDIFF(
date_add(
curdate() - DAY (curdate()) + 1,
INTERVAL 1 MONTH
),
DATE_ADD(
curdate(),
INTERVAL - DAY (curdate()) + 1 DAY
)
)
) +(
DATEDIFF(
DATE_ADD(
curdate(),
INTERVAL - DAY (curdate()) + 1 DAY
),
date_add(
curdate() - DAY (curdate()) + 1,
INTERVAL - 你要往前推几个月 MONTH
)
)
)
FROM
DUAL