웹이야기

MySQL MONTH() 본문

D/MySQL

MySQL MONTH()

yeon.Biju 2020. 4. 2. 13:47

MySQL 날짜함수, 시간함수

 

MONTH()

   - 주어진 날짜로부터 월을 구해준다.

 

MONTH(date)

의 형태로 사용

 

Returns the month for date, in the range 1 to 12 for January to December, or 0 for dates such as '0000-00-00' or '2008-00-00' that hava a zero month part.

 


mysql> SELECT MONTH(NOW());
+--------------+
| MONTH(NOW()) |
+--------------+
|            4 |
+--------------+
1 row in set (0.00 sec)

 

mysql> SELECT MONTH('2020-11-11');
+---------------------+
| MONTH('2020-11-11') |
+---------------------+
|                  11 |
+---------------------+
1 row in set (0.00 sec)

 

mysql> SELECT MONTH('2020-03-50');
+---------------------+
| MONTH('2020-03-50') |
+---------------------+
|                NULL |
+---------------------+
1 row in set, 1 warning (0.00 sec)

 


mysql> SELECT MONTH('2020-03-00');
+---------------------+
| MONTH('2020-03-00') |
+---------------------+
|                   3 |
+---------------------+
1 row in set (0.00 sec)

 

mysql> SELECT MONTH('2020-00-01');
+---------------------+
| MONTH('2020-00-01') |
+---------------------+
|                   0 |
+---------------------+
1 row in set (0.00 sec)


'D > MySQL' 카테고리의 다른 글

MySQL NOW()  (0) 2020.04.02
MySQL MONTHNAME()  (0) 2020.04.02
MySQL MINUTE()  (0) 2020.04.02
MySQL MICROSECOND()  (0) 2020.04.02
MySQL MAKETIME()  (0) 2020.04.02
Comments