# ES 6.0 - Scripted Field HourOfDay with Timezone - error

**URL:** https://discuss.elastic.co/t/es-6-0-scripted-field-hourofday-with-timezone-error/107792
**Category:** Elasticsearch
**Created:** [November 15, 2017, 5:12pm UTC](https://discuss.elastic.co/t/es-6-0-scripted-field-hourofday-with-timezone-error/107792 "2017-11-15T17:12:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mazoutte](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mazoutte/32/120188_2.png) [@mazoutte](https://discuss.elastic.co/u/mazoutte)
#### Post date: [November 15, 2017, 5:12pm UTC](https://discuss.elastic.co/t/es-6-0-scripted-field-hourofday-with-timezone-error/107792/1 "2017-11-15T17:12:24Z")

</div>

Hello,

_First Post Here, I will try to do my best to make a clear presentation._

I recently upgraded ELK on my UAT node from 5.6 to 6.0  
**OS : 2012r2 ; single node.**  
**ELK : 6.0.0**  
**Java : 1.8.0\_151**

I was running a painless scripted field pretty well on 5.6.0 to deduce HourOfDay, as follow :  
Name : **HourOfDay**  
Script : `LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['@timestamp'].value),ZoneId.of('Europe/Paris')).getHour()`

I used this script because of the Timezone I'm using : Europe/Paris ; it's working pretty well on a 5.6 ELK, I'm getting a consistent value for HourOfDay.

Q1 : This scripted field doesn't work anymore on ELK 6.0 ; any clue ?  
-Error when opening Kibana : _Courier Fetch: 5 of 330 shards failed._  
-Error From ES logs : [https://pastebin.com/ST3BUP29](https://pastebin.com/ST3BUP29)

Deleting the scripted field dos not pop the error... I tried the following workaround :

Q2 : Using the scripted field with : `doc["@timestamp"].date.hourOfDay` does not work as intended.  
Only The UTC HourOfDay is shown, and my Timezone is never applied when showing the value.

Regards  
Luc

---

<div class="post-metadata">

### Author: ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)
#### Post date: [November 17, 2017, 6:16pm UTC](https://discuss.elastic.co/t/es-6-0-scripted-field-hourofday-with-timezone-error/107792/2 "2017-11-17T18:16:08Z")

</div>

In 6.0, for a date field, `.value` is a `ReadableDateTime`. In the past this was a `long`. So you will want to call `.value.millis` and the rest of your code should continue to work.

---

<div class="post-metadata">

### Author: ![mazoutte](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mazoutte/32/120188_2.png) [@mazoutte](https://discuss.elastic.co/u/mazoutte)
#### Post date: [November 17, 2017, 6:42pm UTC](https://discuss.elastic.co/t/es-6-0-scripted-field-hourofday-with-timezone-error/107792/3 "2017-11-17T18:42:43Z")

</div>

Hi Ryan,

Thank you for your suggestion, which is working pretty well 😉

For others that would have the same issue , I updated the scripted field as suggested :

`LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['@timestamp'].value.millis),ZoneId.of('Europe/Paris')).getHour()`

Merci beaucoup, Have a nice week-end 😉  
Regards  
Luc

---

<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: [December 15, 2017, 6:42pm UTC](https://discuss.elastic.co/t/es-6-0-scripted-field-hourofday-with-timezone-error/107792/4 "2017-12-15T18:42:47Z")

</div>

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