获取当月总天数+上(几个月)月天数之和
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