简体   繁体   中英

mysql date & timestamp comparison help

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)'
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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM