ios - Data retrieving from sqlite DB between two dates - using objective c -


i using below query date filtering, getting wrong result.

select * transactionshistory  date > "29-01-2015 12:00:00"  , date < "30-01-2015 00:00:00" , userid=abc 

i getting result date column value of 29-jan-2016 records, missing here, can 1 me out of value.

the date format in sql not work because sqlite doesn't have native datetime type, it's stored either string, in yyyy-mm-dd hh:mm:ss.sss format, or numeric value representing number of seconds since 1970-01-01 00:00:00 utc. see date , time types on sqlite.org. note if you're using string representation sequence year, month, day (which, when sorting/querying string field, alphanumeric string sort correctly year first, month, , day, critical when doing queries yours).

if stored dates in database string in dd-mm-yyyy hh:mm:ss format, should consider changing format in saved values 1 of approved date formats. make date interactions database much, easier, allowing queries 1 asked (though, obviously, dd-mm-yyyy replaced yyyy-mm-dd format).


Comments