开发者

mysql date & timestamp comparison help

开发者 https://www.devze.com 2023-01-06 16:13 出处:网络
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 wh开发者_StackOverflowere the timestamp is the same as 7 days from now

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 wh开发者_StackOverflowere 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")
0

精彩评论

暂无评论...
验证码 换一张
取 消