# Kibana-1 hour gap

**URL:** https://discuss.elastic.co/t/kibana-1-hour-gap/124046
**Category:** Kibana
**Created:** [March 15, 2018, 8:39am UTC](https://discuss.elastic.co/t/kibana-1-hour-gap/124046 "2018-03-15T08:39:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![K3vin](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@K3vin](https://discuss.elastic.co/u/K3vin)
#### Post date: [March 15, 2018, 8:39am UTC](https://discuss.elastic.co/t/kibana-1-hour-gap/124046/1 "2018-03-15T08:39:12Z")

</div>

Hello,

I had implemented the stack and now I tried to improve my dashboard.  
I created a script field to get the day of week. It was very easy : doc['@timestamp'].date.dayOfWeek

But when I create a visualize with @timestamp and this script field, I had a 1-hour gap.  
For instance  
14/03/2018 22:50:00 -\> 3 (wednesday) -\> good  
14/03/2018 23:30:00 -\> 3 (wednesday) -\> good  
15/03/2018 00:55:00 -\> 3 (wednesday) -\> incorrect... I'd like to have 4 (thursday)  
15/03/2018 01:05:00 -\> 4 (thursday) -\> good

How can I fix this problem ? Maybe there is a workaround like : [doc['@timestamp'] - 1h].date.dayOfWeek ? For sure, the syntax is not correct. But if you could tell me how I can that, it would be fantastic.

Thank you for helping.

---

<div class="post-metadata">

### Author: ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)
#### Post date: [March 15, 2018, 12:42pm UTC](https://discuss.elastic.co/t/kibana-1-hour-gap/124046/2 "2018-03-15T12:42:58Z")

</div>

Seems like maybe the data is in a different time zone from you (1 hour offset). Kibana displays dates in the time zone of the browser, not the data, so you would see results like that if you are viewing the data in a timezone offset by 1 hour. If that is the case, then your proposed fix would work for you, but not for anyone viewing the data in a different time zone.

---

<div class="post-metadata">

### Author: ![K3vin](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@K3vin](https://discuss.elastic.co/u/K3vin)
#### Post date: [March 15, 2018, 1:28pm UTC](https://discuss.elastic.co/t/kibana-1-hour-gap/124046/3 "2018-03-15T13:28:46Z")

</div>

Thanks for your reply.  
indeed, it seems to me a good reason. I'd like to try my fix. But I don't know the syntax.

What is the good syntax for : [doc['@timestamp'] - 1h].date.dayOfWeek ?

---

<div class="post-metadata">

### Author: ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)
#### Post date: [March 15, 2018, 4:53pm UTC](https://discuss.elastic.co/t/kibana-1-hour-gap/124046/4 "2018-03-15T16:53:16Z")

</div>

This should work:

Instant instant = Instant.ofEpochMilli(doc['@timestamp'].value.getMillis());  
instant = instant.minus(1, ChronoUnit.HOURS);  
return instant.atOffset(ZoneOffset.UTC).get(ChronoField.DAY\_OF\_WEEK);

Be sure to set the type and format of the field to number. You will need to substitute the correct time zone for the data for ZoneOffset.UTC.

---

<div class="post-metadata">

### Author: ![K3vin](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@K3vin](https://discuss.elastic.co/u/K3vin)
#### Post date: [March 19, 2018, 6:11pm UTC](https://discuss.elastic.co/t/kibana-1-hour-gap/124046/5 "2018-03-19T18:11:10Z")

</div>

Yeah, it works very well :-). Thank you Bill\_McConaghy !

---

<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: [April 16, 2018, 6:11pm UTC](https://discuss.elastic.co/t/kibana-1-hour-gap/124046/6 "2018-04-16T18:11:15Z")

</div>

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