homerUK
11-30-2005, 01:18 PM
Hi..
I am trying to query dates stored in my mysql database...
eg:
2005-12-13 (13th Dec 2005)
2006-03-14 (14th Mar 2005)
My SQL query needs to fetch all the records which are X number of months ahead of the current date. eg: I query it saying "get me all records where the date is 1 month from now.... I have used this
(MONTH(date_review)-MONTH(CURDATE()))
which returns 1 - so this is ok - as it's November, and december is one month away.... but when I ask for 3 months - it wont get the records...
I know I somehow need to add the months on - but how do I do this with the year attached too??
Any help is much appreciated!! :)
I am trying to query dates stored in my mysql database...
eg:
2005-12-13 (13th Dec 2005)
2006-03-14 (14th Mar 2005)
My SQL query needs to fetch all the records which are X number of months ahead of the current date. eg: I query it saying "get me all records where the date is 1 month from now.... I have used this
(MONTH(date_review)-MONTH(CURDATE()))
which returns 1 - so this is ok - as it's November, and december is one month away.... but when I ask for 3 months - it wont get the records...
I know I somehow need to add the months on - but how do I do this with the year attached too??
Any help is much appreciated!! :)