MySQL LAST_DAY()
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)