Вопрос

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