웹이야기

MySQL LAST_DAY() 본문

D/MySQL

MySQL LAST_DAY()

yeon.Biju 2020. 4. 2. 12:58

MySQL 날짜함수, 시간함수

 

LAST_DAY()

   - 해당 월의 마지막 날짜를 return.

 

LAST_DAY(date), LAST_DAY(datetime)

의 형태

 

Takes a date or datetime value and returns the corresponding value for the last day of the month. Return NULL if the argument is invalid.

 

mysql> SELECT LAST_DAY(NOW());
+-----------------+
| LAST_DAY(NOW()) |
+-----------------+
| 2020-04-30      |
+-----------------+
1 row in set (0.00 sec)

 

mysql> SELECT LAST_DAY('2018-02-01');
+------------------------+
| LAST_DAY('2018-02-01') |
+------------------------+
| 2018-02-28             |
+------------------------+
1 row in set (0.00 sec)

 

mysql> SELECT LAST_DAY('2019-02-01 12:13:45');
+---------------------------------+
| LAST_DAY('2019-02-01 12:13:45') |
+---------------------------------+
| 2019-02-28                      |
+---------------------------------+
1 row in set (0.00 sec)

 

mysql> SELECT LAST_DAY('0000-02-01 12:13:45');
+---------------------------------+
| LAST_DAY('0000-02-01 12:13:45') |
+---------------------------------+
| 0000-02-28                      |
+---------------------------------+
1 row in set (0.00 sec)

 


mysql> SELECT LAST_DAY('2020-02-30 12:13:45');
+---------------------------------+
| LAST_DAY('2020-02-30 12:13:45') |
+---------------------------------+
| NULL                            |
+---------------------------------+
1 row in set, 1 warning (0.00 sec)

 

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

MySQL MAKEDATE()  (0) 2020.04.02
MySQL LOCALTIME()  (0) 2020.04.02
MySQL HOUR()  (0) 2020.04.02
MySQL GET_FORMAT()  (0) 2020.04.02
MySQL FROM_UNIXTIME()  (0) 2020.04.02
Comments