跳到主要内容
跳到主要内容

MONTHS_DIFF

months_diff

description

Syntax

INT months_diff(DATETIME enddate, DATETIME startdate)

开始时间到结束时间相差几个月

example

mysql> select months_diff('2020-12-25','2020-10-25');
+-----------------------------------------------------------+
| months_diff('2020-12-25 00:00:00', '2020-10-25 00:00:00') |
+-----------------------------------------------------------+
| 2 |
+-----------------------------------------------------------+

keywords

months_diff