Search code examples
ravendblucene.netravendb-studio

Inclusive RavenDB date range query not including matching date values as expected


I am trying to understand date range filters in RavenDB. When I attempt to query for records within a particular date range as follows:

Date:[2015-08-18T06:00:00.000Z TO 2015-08-19T06:00:00.000Z]

The document type being queried contains the following record (which I am expecting to be returned by the above query).

{
    "yada_yada": "stuff",
    "Date": "2015-08-18T06:00:00Z",
    "Source": "Joe Bob",
    "Comments": "The force is strong with this one.",
    "Id": "agentactivities-1"
}

The query returns no results. I've tried to modify the query such as Date:[2015-08-18T06:00:00Z TO 2015-08-19T06:00:00.000Z] (removing the decimal value) with the same result. However, if I remove the Z (Date:[2015-08-18T06:00:00.000 TO 2015-08-19T06:00:00.000Z]), the record is returned by the query. Also, modifying the starting range arg an hour earlier seems to work as well (Date:[2015-08-18T05:00:00.000Z TO 2015-08-19T06:00:00.000Z])

What am I missing here? As I understand it, using the [] symbols should result in an inclusive range so why doesn't the query return this record???


Solution

  • The issue is that your date in the document is not a valid date time value. It need to be with ISO 8601 format date.

    This is the format:

    "yyyy-MM-ddTHH:mm:ss.fffffffzzz"