SELECT
TIMESTAMPDIFF(YEAR, '2023-12-12', NOW()) AS years,
TIMESTAMPDIFF(MONTH, '2023-12-12', NOW()) / 12 AS months,
(DAY (NOW()) - DAY ('2023-12-12' ))/ DAY (LAST_DAY(NOW()))/ 12 AS days
FROM
dual;
years + months + days = 相差的年数
SELECT
TIMESTAMPDIFF(YEAR, '2023-12-12', NOW()) AS years,
TIMESTAMPDIFF(MONTH, '2023-12-12', NOW()) / 12 AS months,
(DAY (NOW()) - DAY ('2023-12-12' ))/ DAY (LAST_DAY(NOW()))/ 12 AS days
FROM
dual;
years + months + days = 相差的年数