0

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.

Roland
  • 826
  • 2
  • 9
  • 24

3 Answers3

2
SELECT * FROM mydatabase WHERE ( current_date > '2011-08-07') AND (current_date < '2011-08-08')

Replace the first date with the day you want information about and then update the second date with the following day.

Kanwaljit Singh
  • 4,339
  • 2
  • 18
  • 21
2

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%'
njzk2
  • 38,969
  • 7
  • 69
  • 107
0

You can directly use date function of sqlite

Select current_date from mydatabase where date(current_date) = '2013-09-25'

instead of

Select current_date from mydatabase where current_date = '2013-09-25'

Extra:- If you want to fetch using time then you can also do that using time function

Select current_date from mydatabase where time(current_date) = '09:25'
Yash Vyas
  • 558
  • 4
  • 24