PERIOD_DIFF()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns the difference in months between two periods.
USAGE
PERIOD_DIFF(period1, period2)
Argument Name | Description |
---|---|
| The two period arguments |
DETAILS
PERIOD_DIFF()
is a date-time function that returns the difference in months between two periods.
The return value is the number of months between the arguments, subtracting the second argument from the first.
Each period argument must be in the format YYYYMM
or YYMM
.
A NULL
is returned if either argument is NULL
.
EXAMPLES
SELECT PERIOD_DIFF(202002, 1902),
PERIOD_DIFF(2002, 201902);
+---------------------------+---------------------------+
| PERIOD_DIFF(202002, 1902) | PERIOD_DIFF(2002, 201902) |
+---------------------------+---------------------------+
| 12 | 12 |
+---------------------------+---------------------------+