# Range filter on dates in elasticssearch

**URL:** <https://discuss.elastic.co/t/range-filter-on-dates-in-elasticssearch/28844>\
**Category:** Elasticsearch\
**Created:** [September 8, 2015, 2:28pm UTC](https://discuss.elastic.co/t/range-filter-on-dates-in-elasticssearch/28844 "2015-09-08T14:28:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Diaz\_Gonzalez](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@Juan\_Diaz\_Gonzalez](https://discuss.elastic.co/u/Juan_Diaz_Gonzalez)\
**Post date:** [September 8, 2015, 2:28pm UTC](https://discuss.elastic.co/t/range-filter-on-dates-in-elasticssearch/28844/1 "2015-09-08T14:28:58Z")

</div>

Hi,

I have this mapping:

```
"new_gompute_history_2015-09-08_10:09:27": {
      "mappings": {
         "linux_user_history": {
            "properties": {
               "oid": {
                  "type": "string",
                  "index": "not_analyzed"
               },
               "updated_at": {
                  "type": "date",
                  "format": "dateOptionalTime"
               },
 ....

```

But now when I want to do a filter query with the range filter it does not work correctly for example:

```
GET new_gompute_history_2015-09-08_10:09:27/linux_user_history/_search
{
  "query": {
    "filtered": {
      "filter": {
        "range": {
          "updated_at": {
            "gte": "now-1h"
          }
        }
      }
    }
  }
}

```

And now It´s :

16:23 Tuesday, 8th of September 2015 (CEST)

and from elasticsearch I get:

```
{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "new_gompute_history_2015-09-08_10:09:27",
            "_type": "linux_user_history",
            "_id": "oid:user:jdiazg",
            "_score": 1,
            "_source": {
               "oid": "oid:user:jdiazg",
               updated_at": "2015-09-08T14:43:44.920229,
               "versions": [
                  {
                     "dn": {

```

**updated\_at": "2015-09-08T14:43:44.920229**** \< ****now-1h = 2015-09-08T15:23:00.00000**

Please could somebody tell me what is wrong?

Thanks in advance

---

<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:** [July 5, 2017, 11:51pm UTC](https://discuss.elastic.co/t/range-filter-on-dates-in-elasticssearch/28844/2 "2017-07-05T23:51:39Z")

</div>


