我正在尝试获取两个日期之间的日期,但我无法解决。是因为我的日期格式错误还是我遗漏了其他东西???
SELECT * FROM (`employee`) WHERE `date` BETWEEN 2013-06-03 AND 2013-06-05
我正在尝试获取两个日期之间的日期,但我无法解决。是因为我的日期格式错误还是我遗漏了其他东西???
SELECT * FROM (`employee`) WHERE `date` BETWEEN 2013-06-03 AND 2013-06-05
我以前从未在语句之间使用过,
我认为应该是;
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'";
我认为比较日期的unix时间戳应该适合你:
SELECT * FROM emloyee WHERE
UNIX_TIMESTAMP( date ) >= UNIX_TIMESTAMP('2013-06-03')
AND UNIX_TIMESTAMP( date ) <= UNIX_TIMESTAMP('2013-06-05')
尝试这个
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');