I am using NSDate for date/time representation in DBAccess framework. However, when I run SQL queries like
select date(start) from actions
I got strange date instead of my date. Even DBAccess queries doesn't work, like:
DBResultSet *today = [[[Actions query] where:@"date(end) = date('now')"] fetch];
In SQLite the column type is correct - timestamp. So that is there any way how to work correctly with dates / times?
Thanks,
Jindrich
I finally ended with using sqlite functions, instead of converting NSDate, as @Adrian_H suggests. My code for today items looks like:
DBResultSet *today = [[[[Actions query] where:@"date(datetime(end, 'unixepoch', 'localtime')) = date('now')"] orderByDescending:@"id"] fetch];
This results items, where end value is today.