I Have application can running in 3 databases with Yii framework.
Example table with field (id, selectdate)
1 2015-10-04 10:10:24
2 2015-10-04 21:10:24
3 2015-09-20 11:10:24
I want to query with where = 2015-10-04. How to query ??
SELECT id, SUBSTRING(selectdate, 0, 11) AS scandate FROM scan WHERE scandate = ‘2015-10-04’ ==> can not running well
phtamas
(Phtamas)
2
Try to compare dates as dates (rather than strings). It’s usually faster, more intuitive and more reliable.
WHERE selectdate >= '2015-10-04' AND selectdate < '2015-10-05'
Or, for MySQL:
WHERE DATE(selectdate) = '2015-10-04'
oligalma
(Marc Oliveras)
3
You can also use the BETWEEN keyword:
WHERE selectdate BETWEEN '2015-10-04' AND '2015-10-05'