Skip navigation links

MySQL Forums :: Newbie :: Check dates


Advanced Search

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
Check dates Chevy Mark Sunderland 02/20/2012 04:28AM
Re: Check dates laptop alias 02/20/2012 07:46AM
Re: Check dates Chevy Mark Sunderland 02/20/2012 08:18AM
Re: Check dates laptop alias 02/20/2012 07:16AM
Re: Check dates Chevy Mark Sunderland 02/20/2012 01:48PM
Re: Check dates Rick James 02/25/2012 12:12AM
Re: Check dates Chevy Mark Sunderland 02/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.