# Timestamps in Range Query

**URL:** <https://discuss.elastic.co/t/timestamps-in-range-query/95219>\
**Category:** Elasticsearch\
**Created:** [July 31, 2017, 4:53pm UTC](https://discuss.elastic.co/t/timestamps-in-range-query/95219 "2017-07-31T16:53:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kryten](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@Kryten](https://discuss.elastic.co/u/Kryten)\
**Post date:** [July 31, 2017, 4:53pm UTC](https://discuss.elastic.co/t/timestamps-in-range-query/95219/1 "2017-07-31T16:53:31Z")

</div>

Hi,  
Would appreciate any assistance.

I'm trying to get some data using this query:

```
POST /agents-*/_search
{
  "facets": {
    "2": {
      "query": {
        "filtered": {
          "query": {
            "query_string": {
              "query": "message_details:\"Starting shift\""
            }
          },
          "filter": {
            "bool": {
              "must": [
                {
                  "range": {
                    "@timestamp": {
                      "from": "2017-07-31T10:00:00.000",
                      "to": "2017-07-31T12:00:00.000"
                    }
                  }
                }
              ]
            }
          }
        }
      }
    }
  },
  "size": 0
}

```

But getting no useful data back.

the same query works perfectly when the @tiimestamp range is changed to:

```
 "@timestamp": {
                      "from": "now-2h",
                      "to": "now"

```

it also seems to work okay when the timestamp(s) are provided as Unix time (seconds since epoch?).

How to write this query so I can use timestamps like:

```
"from": "2017-07-31T10:00:00.000",
"to": "2017-07-31T12:00:00.000"

```

In my query.

Possible?

Thanks.

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [July 31, 2017, 8:22pm UTC](https://discuss.elastic.co/t/timestamps-in-range-query/95219/2 "2017-07-31T20:22:05Z")

</div>

Hi,

you can find more informations here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math)

you can try your query with:

from = "2017-07-31T10:00:00.000||-2h/h"  
to "2017-07-31T10:00:00.000"

bye,  
Xavier

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 28, 2017, 8:22pm UTC](https://discuss.elastic.co/t/timestamps-in-range-query/95219/3 "2017-08-28T20:22:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
