mySQL dateTime范围查询问题 [英] mySQL dateTime range Query Issue
问题描述
到目前为止,我的查询如下所示:
SELECT * FROM util_audit WHERE DATED> = DATE 03/15/2012)和日期(03/31/2012);
如果我只是使用
SELECT * FROM util_audit WHERE DATED> = DATE(03/15/2012);
它将返回我所有的记录,因为它们是本周的日期。
我也尝试过:
SELECT * FROM util_audit WHERE DATED> = '02 / 15 / 2012 00:00:00'AND DATED< = '03 / 31/2012 00:00:00';
没有!它会返回零行,当我知道我所有的日期从本月27日到今天。我在这里遗漏了什么吗?为什么它自己工作,但不是当我添加第二个日期?我可能忽略了一些。
尝试:
SELECT * FROM util_audit WHERE`DATED` BETWEEN2012-03-15AND2012-03-31;
I have a quick question. I'm have a db an audit Table with a datetime column in it. (i.e 2012-03-27 00:00:00) and I'm building a mySQL query to return a set of rows if the date is in between the two dates I'm giving it.
so far my query looks like this:
SELECT * FROM util_audit WHERE DATED >= DATE(03/15/2012) AND DATED <= DATE(03/31/2012);
if I just use
SELECT * FROM util_audit WHERE DATED >= DATE(03/15/2012);
It'll return all my record because they were dated this week.
I also tried this:
SELECT * FROM util_audit WHERE DATED >= '02/15/2012 00:00:00' AND DATED <= '03/31/2012 00:00:00';
and nothing! It'll return zero rows, when I know I have all of them dated from the 27 of this month to today. Am I missing something here? why does it work on its own, but not when I add the second date?I'm probably overlooking something.
Try:
SELECT * FROM util_audit WHERE `DATED` BETWEEN "2012-03-15" AND "2012-03-31";
这篇关于mySQL dateTime范围查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!