我试图从数据库中找出最近5天的日期和时间,插入表格的数据是日期形式(" Y-m-d h:i:s"); 现在,当我尝试检索它时,值将不会显示,直到删除表中的时间 我的查询是:
SELECT Key,DATE_FORMAT(lastUpdated, '%D %M %Y')
FROM table
WHERE lastUpdated Between NOW() - INTERVAL 5 DAY AND NOW()
ORDER BY Key DESC;
答案 0 :(得分:1)
我相信您只想比较lastUpdated
的DATE() SELECT Key,DATE_FORMAT(lastUpdated, '%D %M %Y')
FROM table
WHERE DATE(lastUpdated) Between NOW() - INTERVAL 5 DAY AND NOW()
ORDER BY Key DESC;