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

YEARS_DIFF

years_diff

description

Syntax

INT years_diff(DATETIME enddate, DATETIME startdate)

开始时间到结束时间相差几年

example

mysql> select years_diff('2020-12-25','2019-10-25');
+----------------------------------------------------------+
| years_diff('2020-12-25 00:00:00', '2019-10-25 00:00:00') |
+----------------------------------------------------------+
| 1 |
+----------------------------------------------------------+

keywords

years_diff