# Day of Week aggregation with TimeZone

**URL:** <https://discuss.elastic.co/t/day-of-week-aggregation-with-timezone/81924>\
**Category:** Elasticsearch\
**Created:** [April 11, 2017, 7:12am UTC](https://discuss.elastic.co/t/day-of-week-aggregation-with-timezone/81924 "2017-04-11T07:12:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paulo\_Henrique\_PH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulo_henrique_ph/32/14831_2.png) [@Paulo\_Henrique\_PH](https://discuss.elastic.co/u/Paulo_Henrique_PH)\
**Post date:** [April 11, 2017, 7:12am UTC](https://discuss.elastic.co/t/day-of-week-aggregation-with-timezone/81924/1 "2017-04-11T07:12:08Z")

</div>

I use ES 5.1.2 and I'm trying to compute day of week and time of day from a date field and consider timezone at the same time.

my first script is def `d = doc['my_field'].date; d.addHours(10); d.getDayOfWeek();`

The error message is can't find addHours() method

```
"caused_by": {
    "type": "illegal_argument_exception",
    "reason": "Unable to find dynamic method [addHours] with [1] arguments for class [org.joda.time.MutableDateTime]."
},
"script_stack": [
    "d.addHours(10); ",
    " ^---- HERE"
],

```

If I change script to `MutableDateTime d = doc['my_field'].date; d.addHours(10); d.getDayOfWeek();` The error message becomes

```
"caused_by": {
  "type": "illegal_argument_exception",
  "reason": "unexpected token ['d'] was expecting one of [{<EOF>, ';'}]."
},
"script_stack": [
  "MutableDateTime d = doc['relation_denstu. ...",
  " ^---- HERE"
],

```

Without addHours to adjust timezone, everything is fine. But if I try to adjust timezone dynamically, everything failed. Any help?

---

<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:** [May 9, 2017, 7:19am UTC](https://discuss.elastic.co/t/day-of-week-aggregation-with-timezone/81924/2 "2017-05-09T07:19:06Z")

</div>

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