# Minus timezone on date histogram aggregation shifts back buckets one day

**URL:** <https://discuss.elastic.co/t/minus-timezone-on-date-histogram-aggregation-shifts-back-buckets-one-day/262959>\
**Category:** Elasticsearch\
**Created:** [February 2, 2021, 10:28am UTC](https://discuss.elastic.co/t/minus-timezone-on-date-histogram-aggregation-shifts-back-buckets-one-day/262959 "2021-02-02T10:28:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anas-hossam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anas-hossam/32/82862_2.png) [@anas-hossam](https://discuss.elastic.co/u/anas-hossam)\
**Post date:** [February 2, 2021, 10:28am UTC](https://discuss.elastic.co/t/minus-timezone-on-date-histogram-aggregation-shifts-back-buckets-one-day/262959/1 "2021-02-02T10:28:03Z")

</div>

this is my body request when search in elasticsearch version 1.5

```auto
{
    "body": {
        "size": 0,
        "query": {
            "filtered": {
                "filter": {
                    "bool": {
                        "must": [
                            {
                                "range": {
                                    "create_time": {
                                        "gte": "2020-09-02T00:00:00",
                                        "lte": "2020-09-05T23:59:59",
                                        "time_zone": "-2:00"
                                    }
                                }
                            }
                        ]
                    }
                }
            }
        },
        "aggs": {
            "posts_over_time": {
                "date_histogram": {
                    "field": "create_time",
                    "interval": "day",
                    "min_doc_count": 0,
                    "time_zone": "-2:00",
                    "format": "yyyy-MM-dd",
                    "extended_bounds": {
                        "min": "2020-09-02",
                        "max": "2020-09-05"
                    }
                },
                "aggs": {
                    "Sum of engagements": {
                        "sum": {
                            "field": "interactions_count"
                        }
                    }
                }
            }
        }
    }
}

```

and result is shifted back one day return buckets from day `2020-09-01` to day `2020-09-04` not from day `2020-09-02` to day `2020-09-05` as expected

how to make result respect range without shifting and return result by the timezone of query ?

---

<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:** [March 2, 2021, 10:28am UTC](https://discuss.elastic.co/t/minus-timezone-on-date-histogram-aggregation-shifts-back-buckets-one-day/262959/2 "2021-03-02T10:28:55Z")

</div>

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