# How to return whole date range in Date Histogram aggegation

**URL:** <https://discuss.elastic.co/t/how-to-return-whole-date-range-in-date-histogram-aggegation/117531>\
**Category:** Elasticsearch\
**Created:** [January 29, 2018, 8:27pm UTC](https://discuss.elastic.co/t/how-to-return-whole-date-range-in-date-histogram-aggegation/117531 "2018-01-29T20:27:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smlbiobot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smlbiobot/32/29622_2.png) [@smlbiobot](https://discuss.elastic.co/u/smlbiobot)\
**Post date:** [January 29, 2018, 8:27pm UTC](https://discuss.elastic.co/t/how-to-return-whole-date-range-in-date-histogram-aggegation/117531/1 "2018-01-29T20:27:17Z")

</div>

I am using Date Histogram to aggregation values over time. The problem is that I see that if that date has no data, it just omits it completely. What I need it to do is enter it as null. I try to use `missing` and also `min_doc_count` set to 0 but the result is still the same.

Partial requests:

```json
"aggs": {
            "winner_over_time": {
                "terms": {
                    "field": "winner",
                    "size": 10,
                    "order": {
                        "_term": "asc"
                    }
                },
                "aggs": {
                    "count_over_time": {
                        "date_histogram": {
                            "field": "timestamp",
                            "interval": interval,
                            "min_doc_count": 0,
                            "missing": 0
                        }
                    }
                }
            },

```

Partial response:

```auto
    "aggregations": {
        "winner_over_time": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
                {
                    "key": -3,
                    "doc_count": 1,
                    "count_over_time": {
                        "buckets": [
                            {
                                "key_as_string": "2018-01-29T05:00:00.000Z",
                                "key": 1517202000000,
                                "doc_count": 1
                            }
                        ]
                    }
                },
                {
                    "key": -1,
                    "doc_count": 3,
                    "count_over_time": {
                        "buckets": [
                            {
                                "key_as_string": "2018-01-29T00:00:00.000Z",
                                "key": 1517184000000,
                                "doc_count": 1
                            },
                            {
                                "key_as_string": "2018-01-29T01:00:00.000Z",
                                "key": 1517187600000,
                                "doc_count": 1
                            },
                            {
                                "key_as_string": "2018-01-29T02:00:00.000Z",
                                "key": 1517191200000,
                                "doc_count": 0
                            },
                            {
                                "key_as_string": "2018-01-29T03:00:00.000Z",
                                "key": 1517194800000,
                                "doc_count": 0
                            },
                            {
                                "key_as_string": "2018-01-29T04:00:00.000Z",
                                "key": 1517198400000,
                                "doc_count": 0
                            },
                            {
                                "key_as_string": "2018-01-29T05:00:00.000Z",
                                "key": 1517202000000,
                                "doc_count": 1
                            }
                        ]
                    }
                },

```

As you see, for `"key": -3`, it only returned one data point for me. I need it to return everything within the series. Right now I had to go into the data and manually insert missing time keys for my charting library. I would prefer to not have to do that.

---

<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:** [February 26, 2018, 8:27pm UTC](https://discuss.elastic.co/t/how-to-return-whole-date-range-in-date-histogram-aggegation/117531/2 "2018-02-26T20:27:22Z")

</div>

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