Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the next month for given date in mysql

Tags:

mysql

Find the COUNT(next month Between next month +2DAYS) for the created date in table(including Year wise Dec ,Jan like)

How to do this using mysql query Query need for both datatype date and datetime

like image 431
Mohan Avatar asked Dec 06 '25 16:12

Mohan


2 Answers

If you only want the MONTH, then use SELECT MONTH('2011-03-28' + INTERVAL 1 MONTH)

Works the same for DATE and DATETIME (replace the actual date I quoted with your own SQL and column name). For more info you can refer to http://dev.mysql.com/doc/refman/5.1/en/datetime.html

like image 182
Michael J.V. Avatar answered Dec 08 '25 05:12

Michael J.V.


SELECT COUNT(whatever)
FROM
yourTable
WHERE
yourDateColumn BETWEEN NOW()+INTERVAL 1 MONTH AND NOW()+INTERVAL 1 MONTH + INTERVAL 2 DAYS
like image 33
fancyPants Avatar answered Dec 08 '25 06:12

fancyPants



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!