MySQL Forums
Forum List  »  Newbie

Re: Check dates
Posted by: Rick James
Date: February 25, 2012 12:12AM

> Now I need make the number of days in the month returned by ADDDATE(CURDATE(),INTERVAL - 1 YEAR).

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_last-day

mysql> SELECT @day := ADDDATE(CURDATE(),INTERVAL - 1 YEAR);
+----------------------------------------------+
| @day := ADDDATE(CURDATE(),INTERVAL - 1 YEAR) |
+----------------------------------------------+
| 2011-02-24                                   |
+----------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT DAYOFMONTH(LAST_DAY(@day)) AS DaysInMonth;
+-------------+
| DaysInMonth |
+-------------+
|          28 |
+-------------+
1 row in set (0.00 sec)



Edited 1 time(s). Last edit at 02/25/2012 12:13AM by Rick James.

Options: ReplyQuote


Subject
Written By
Posted
February 20, 2012 04:28AM
February 20, 2012 07:46AM
February 20, 2012 08:18AM
February 20, 2012 07:16AM
February 20, 2012 01:48PM
Re: Check dates
February 25, 2012 12:12AM
February 24, 2012 07:56PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.