Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-440

DateTime in base with milliseconds. DateTime via Query - without. Query.Eq - doesn't work with DateTime properties

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.4.1
    • Affects Version/s: 1.3.1, 1.4
    • Component/s: None
    • None

      When I want to store DateTime it stored like:

      bsonWriter.WriteString(dateTime.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFFK"));

      Problem:
      Now I want to query my DateTime property by Eq query. Query Serializer generate something like: "Property":ISODate("2012-04-13T06:00:00Z")

      And I got empty result set, because dates doesn't match - date in base with milliseconds, generated date - without

      I can do only workaround about this:
      "DateTimeProperty" :

      { "$gte" : ISODate("2012-04-13T06:00:00Z"), "$lt" : ISODate("2012-04-13T06:00:01Z") }

      Like "query Date" <= DateTime < "query Date" + 1 seconds (to handle milliseconds)

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            gfx00 Brian
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: