ios - Core Date - Predicate for filtering dates -


i have cd entity has date attribute. when doing fetchrequest pass predicate on it:

nspredicate* predicate = [nspredicate predicatewithformat:@"(eventstartdate >=%@) , (eventstartdate <=%@)", startofday, endofday]; 

these dates passing:

first date:2015-07-10 00:00:00 +0000  second date:2015-07-10 11:59:59 +0000 

i know there 1 item matches query (starts after midnight today before 11:59:59 today) not being returned predicate. if rewrite or conditional, returns previous dates. if have greater condition current , future dates returned. how can write items match today's date?

thanks

here how formatting seconddate. did have 11 instead of 23 :

nsdate* today = [[nsdate alloc] init];  nscalendar* currentcalendar = [nscalendar currentcalendar]; [currentcalendar settimezone:[nstimezone timezonewithname:@"gmt"]];  nsdatecomponents* datecomponents = [currentcalendar components:nscalendarunitmonth | nscalendarunitday | nscalendarunityear fromdate:today];  nsinteger thismonth = [datecomponents month]; nsinteger thisday = [datecomponents day]; nsinteger thisyear = [datecomponents year];  nsdatecomponents* endoddaycomponents = [[nsdatecomponents alloc] init]; [endoddaycomponents setday:thisday]; [endoddaycomponents setmonth:thismonth]; [endoddaycomponents setyear:thisyear]; [endoddaycomponents sethour:11]; [endoddaycomponents setminute:59]; [endoddaycomponents setsecond:59];  return [currentcalendar datefromcomponents:endoddaycomponents]; 


Comments