Search code examples
odatabreeze

Breeze: Filtering by Date only on a DateTime type


I'm passing in the following Predicate into an EntityQuery but no results are being returned even tho I have data for the specified date:

// query equals 'Wed Feb 05 2014 00:00:00 GMT+0000 (GMT Standard Time)'
Predicate.create('createdDateTime', '==', query);

This creates the following query in oData:

$filter=CreatedDateTime%20eq%20datetime%272014-02-05T00%3A00%3A00.000Z%27

The data held in the database also has the time value: 2014-02-05 14:18:02.590, so I guess this is why no data is returned? So my question is, how can I filter just on the Date value, ignoring the time?


Solution

  • DateTime queries are tricky everywhere particularly when you consider that server time and client time are often unaligned. Time zone considerations can lead to madness. It's not really a Breeze problem per se.

    With those caveats in mind, consider how best to bracket the date you care about (with greaterThan/lessThan) logic. It gets vastly easier if you eliminate the time component altogether by storing some kind of normalized date-only value in UTC. Wish I knew a better answer.