View Single Post

  #2 (permalink)  
Old 24-07-2008, 01:40 PM
jmcc's Avatar
jmcc jmcc is offline
Wannabe Geek
 
Join Date: Feb 2006
Posts: 311
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
jmcc is just really nicejmcc is just really nicejmcc is just really nicejmcc is just really nice
Default

Quote:
Originally Posted by louie View Post
Does any of you came across a PHP function to be able to remove 3 months from a specific date.

I need to find records in the DB based on start date YEAR-MONTH-01 minus 3months and end date YEAR-MONTH-31, 30 or 28 minus 3 month depending on the dates given.
Not sure about PHP but I think that the DATE_SUB() function in MySQL will allow you to subtract months. Something like this:
SELECT DATE_SUB('2008-08-01', INTERVAL 3 MONTH);

I haven't used this function recently. It may also be dependent on the version of MySQL. Works in 4.n and 5.n.

Regards...jmcc

Last edited by jmcc; 24-07-2008 at 01:44 PM. Reason: sqlising
Reply With Quote