「MariaDB」PERIOD_DIFF関数でYYYYMM形式の日付の差分を取得する

環境
MariaDB 10.6.4

書式
PERIOD_DIFF( YYYYMM, YYYYMM )
PERIOD_DIFF()関数を利用して、YYYYMM形式の日付の差分を取得します。

使用例1

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> SELECT PERIOD_DIFF(202009,202002) result;
+--------+
| result |
+--------+
| 7 |
+--------+
1 row in set (0.000 sec)
MariaDB [(none)]> SELECT PERIOD_DIFF(202009,202002) result; +--------+ | result | +--------+ | 7 | +--------+ 1 row in set (0.000 sec)
MariaDB [(none)]> SELECT PERIOD_DIFF(202009,202002) result;
+--------+
| result |
+--------+
|      7 |
+--------+
1 row in set (0.000 sec)

使用例2

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> SELECT PERIOD_DIFF(201901,201812) result;
+--------+
| result |
+--------+
| 1 |
+--------+
1 row in set (0.000 sec)
MariaDB [(none)]> SELECT PERIOD_DIFF(201901,201812) result; +--------+ | result | +--------+ | 1 | +--------+ 1 row in set (0.000 sec)
MariaDB [(none)]> SELECT PERIOD_DIFF(201901,201812) result;
+--------+
| result |
+--------+
|      1 |
+--------+
1 row in set (0.000 sec)

 

MariaDB

Posted by arkgame