0

我正在尝试获取两个日期之间的日期,但我无法解决。是因为我的日期格式错误还是我遗漏了其他东西???

       SELECT * FROM (`employee`) WHERE `date` BETWEEN 2013-06-03 AND 2013-06-05
4

3 回答 3

0

我以前从未在语句之间使用过,

我认为应该是;

SELECT * FROM (`employee`) WHERE `date` BETWEEN "2013-06-03" AND "2013-06-05"

带引号,只是一个错字...

我个人更喜欢;

SELECT * FROM employee WHERE Date >= '03/06/2013' AND Date <= '05/06/2013'";
于 2013-06-20T11:59:11.620 回答
0

我认为比较日期的unix时间戳应该适合你:

SELECT * FROM emloyee WHERE 
     UNIX_TIMESTAMP( date ) >= UNIX_TIMESTAMP('2013-06-03') 
 AND UNIX_TIMESTAMP( date ) <= UNIX_TIMESTAMP('2013-06-05') 

参考:MYSQL UNIX_TIMESTAMP()

于 2013-06-20T11:59:16.110 回答
0

尝试这个

SELECT * FROM (`employee`) WHERE `date` BETWEEN STR_TO_DATE('2013-06-03','%Y-%m-%d') AND STR_TO_DATE('2013-06-05','%Y-%m-%d');
于 2013-06-20T12:23:12.133 回答