Search code examples
mysqlweb-serviceshibernatenamed-query

Selecting records based on date from MySQL


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?


Solution

  • 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'