MySQL Forums
Forum List  »  Newbie

Query for 3 months back
Posted by: greg dove
Date: January 07, 2013 12:49PM

I am looking to select tickets from the previous 3 months. By calculate the previous 3 months.

This query sorta-works:

select created, datediff( now(), created) as period , now() FROM tickets WHERE DATE_SUB(NOW(), INTERVAL 3 MONTH) < created

However "INTERVAL 3 MONTH" appears to use 30 as a constant in a month.
So October, December, have 31 days. But the INTERVAL MONTH is using 30 days.

Does anyone know a workaround, to get the correct 3 months?


Options: ReplyQuote

Written By
Query for 3 months back
January 07, 2013 12:49PM
January 07, 2013 02:40PM
January 08, 2013 09:23AM
January 08, 2013 09:26AM
January 08, 2013 03:04PM

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.