tags:

views:

15

answers:

1

Hi, hoping you guys can help - I have a timestamp column in my db table and i want to run a query to find any records from that table where the timestamp is the same as 7 days from now (ignoring the hours, minutes and seconds). So far I have this but I'm certain it's not what i should be doing:

WHERE `import_date` = 'DATE_SUB(NOW(), INTERVAL 7 days)'
A: 
WHERE import_date = 'DATE_SUB(NOW(), INTERVAL 7 days)'

should be

WHERE import_date >= DATE_SUB(NOW(), INTERVAL 7 day)

days should be day

for timestamp same as 7 day before from now use

WHERE DATE_FORMAT(`import_date`, "%Y-%m-%d") = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 7 day), "%Y-%m-%d")
Salil
Thanks Salil, ah my mistake on the "day". I actually only want to look for an exact match with import_date and 7 days ago, which means I need to strip out the hours minutes and seconds of the timestamp and compare it with 7 days from the current date.
steve-o