Search code examples
androidsqlsqlitedatetimeandroid-date

How to search in sqlite by date?


I'm saving im my table a colum current_date in this format: 'yyyy-MM-dd HH:mm'

How to search in database by date? I want, for examble the records from 2013-09-25 discarting the hour.

If I do this "Select current_date from mydatabase where current_date = '2013-09-25'" It does not work. I have to make this "Select current_date from mydatabase where current_date = '2013-09-25 09:25'". But i want only the record based on the date, not based on the date and hour.


Solution

  • Apparently your dates are stored as Strings. You can use LIKE to discard the hour :

     select current_date from mydatabase where current_date like '2013-09-25%'