MySQL 8.0.29で日付から月の英語表記を取得する

環境
Ubuntu 22.04 LTS
MySQL 8.0.29-0ubuntu0.22.04.2

書式
MONTHNAME( 日時 )
MONTHNAME関数を使用して、日付から月の英語表記を取得します。

使用例1

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> SELECT
-> MONTHNAME( '2022/1/04' ) resA,
-> MONTHNAME( '2022/02/5' ) resB,
-> MONTHNAME( '2022/3/6' )resC;
+---------+----------+-------+
| resA | resB | resC |
+---------+----------+-------+
| January | February | March |
+---------+----------+-------+
1 row in set, 3 warnings (0.00 sec)
mysql> SELECT -> MONTHNAME( '2022/1/04' ) resA, -> MONTHNAME( '2022/02/5' ) resB, -> MONTHNAME( '2022/3/6' )resC; +---------+----------+-------+ | resA | resB | resC | +---------+----------+-------+ | January | February | March | +---------+----------+-------+ 1 row in set, 3 warnings (0.00 sec)
mysql> SELECT
    -> MONTHNAME( '2022/1/04' ) resA,
    -> MONTHNAME( '2022/02/5' ) resB,
    -> MONTHNAME( '2022/3/6' )resC;
+---------+----------+-------+
| resA    | resB     | resC  |
+---------+----------+-------+
| January | February | March |
+---------+----------+-------+
1 row in set, 3 warnings (0.00 sec)

使用例2

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> SELECT
-> MONTHNAME( '2022/12/31' ) resA,
-> MONTHNAME( '2022/11/11 12:12:13' ) resB;
+----------+----------+
| resA | resB |
+----------+----------+
| December | November |
+----------+----------+
1 row in set, 2 warnings (0.00 sec)
mysql> SELECT -> MONTHNAME( '2022/12/31' ) resA, -> MONTHNAME( '2022/11/11 12:12:13' ) resB; +----------+----------+ | resA | resB | +----------+----------+ | December | November | +----------+----------+ 1 row in set, 2 warnings (0.00 sec)
mysql> SELECT
    -> MONTHNAME( '2022/12/31' ) resA,
    -> MONTHNAME( '2022/11/11 12:12:13' ) resB;
+----------+----------+
| resA     | resB     |
+----------+----------+
| December | November |
+----------+----------+
1 row in set, 2 warnings (0.00 sec)

 

MySQL

Posted by arkgame