Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

carlosbutler

macrumors 6502a
Original poster
Is it possible to be able to have an SQL query that is able to search through dates with +/- a few days?

For example if looking for a record with a date on 2009-04-01, could it be expanded to have a range from 2009-03-30 -> 2009-04-03?

I can guess you are able to do something like:

select * from 'something' where date < '2009-04-03' and date > '2009-03-30';

But I am not sure how to get it so that it adds/decreases the dates for the search statement

Thanks
 
Not automatically, but if you don't want to calculate the days:

Code:
WHERE <column> BETWEEN DATE_SUB('2009-04-01', INTERVAL 3 DAY) AND DATE_ADD('2009-04-01', INTERVAL 3 DAY)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.