# hourOfWeek aggregation attempt results do not match date histogram by hour aggregation

**URL:** <https://discuss.elastic.co/t/hourofweek-aggregation-attempt-results-do-not-match-date-histogram-by-hour-aggregation/94252>\
**Category:** Elasticsearch\
**Created:** [July 23, 2017, 7:01pm UTC](https://discuss.elastic.co/t/hourofweek-aggregation-attempt-results-do-not-match-date-histogram-by-hour-aggregation/94252 "2017-07-23T19:01:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dustin\_Decker](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@Dustin\_Decker](https://discuss.elastic.co/u/Dustin_Decker)\
**Post date:** [July 23, 2017, 7:01pm UTC](https://discuss.elastic.co/t/hourofweek-aggregation-attempt-results-do-not-match-date-histogram-by-hour-aggregation/94252/1 "2017-07-23T19:01:18Z")

</div>

I'm trying to replicate the results of this data histogram aggregation but bucket by hour of week (0 through 168) instead:

```auto
"dateByHour": {
      "date_histogram": {
        "field": "event_timestamp",
        "interval": "1h",
        "time_zone": "America/Chicago",
        "min_doc_count": 1
      }
 }

```

My attempt is delivering similar results for some hours, and results about 5x off for others:

```auto
"hourOfWeek": {
    "terms": {
        "script": {
            "lang": "painless",
            "inline": "doc['event_timestamp'].date.dayOfWeek * doc['event_timestamp'].date.hourOfDay"
        },
        "size": 168
    }
}

```

Any ideas of what I may be doing incorrectly?

---

<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 20, 2017, 7:01pm UTC](https://discuss.elastic.co/t/hourofweek-aggregation-attempt-results-do-not-match-date-histogram-by-hour-aggregation/94252/2 "2017-08-20T19:01:50Z")

</div>

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