I have two columns in my table say Id, date. date is date timestamp (eg:2014-04-01 02:30:00).

I want to return all the records based on the date (2014-04-01) instead of giving entire time stamp. How can I achieve this?

有帮助吗?

解决方案

If you don't care about index, use the following:

select Id from table where DATE(date) = '2014-04-01'

otherwise

select Id from table where date between '2014-04-01 00:00:00' and '2014-04-01 23:59:59'

其他提示

Try Thiz

select id from table where DATE(date)='2014-04-01';

Try this

SELECT p
FROM Customer p
WHERE code =?1
  AND DATE_FORMAT(time, '%Y%m%d') BETWEEN "2014-04-01" AND "2014-04-30"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top