문제

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