I am fetching records from Core Data between two timestamps which represent the start and end of the day using the following predicate:
let timeStampPredicate = NSPredicate(format: "timestamp >= %f AND timestamp < %f", startTimeStamp, endTimeStamp)
The above predicate works perfectly until 11:59:00 PM, but any record saved after it, like at 11:59:22 PM are not returned by the predicate.
Example:
Records in Core Data :
Record 1:
Timestamp: 1631816962.0
Date: 2021-09-16 18:29:22 +0000 // My TimeZone is +0530
Challenge ID: 1
Value: 100.0
Record 2:
Timestamp: 1631816902.0
Date: 2021-09-16 18:28:22 +0000 // My TimeZone is +0530
Challenge ID: 1
Value: 100.0
Passed Values to the predicate:
startTimeStamp : 1631730600.0 // 2021-09-15 18:30:00 +0000
endTimeStamp : 1631817000.0 // 2021-09-16 18:30:00 +0000
When I execute the predicate only 1 record is returned which is inserted before 11:59:00 PM
Can anyone help me understand what's happening or what I am doing wrong.