如何使用MySQL在两个日期之间进行查询? [英] How do I query between two dates using MySQL?
本文介绍了如何使用MySQL在两个日期之间进行查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下查询:
SELECT * FROM `objects`
WHERE (date_field BETWEEN '2010-09-29 10:15:55' AND '2010-01-30 14:15:55')
不返回任何内容.
我应该有足够多的数据来使查询工作.我在做什么错了?
I should have more than enough data to for the query to work though. What am I doing wrong?
推荐答案
您的第二个日期早于您的第一个日期(即,您正在查询2010年9月29日至2010年1月30日之间).尝试颠倒日期顺序:
Your second date is before your first date (ie. you are querying between September 29 2010 and January 30 2010). Try reversing the order of the dates:
SELECT *
FROM `objects`
WHERE (date_field BETWEEN '2010-01-30 14:15:55' AND '2010-09-29 10:15:55')
这篇关于如何使用MySQL在两个日期之间进行查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文