# HistogramFacet & date oddness

**URL:** <https://discuss.elastic.co/t/histogramfacet-date-oddness/3672>\
**Category:** Elasticsearch\
**Created:** [December 16, 2010, 6:14pm UTC](https://discuss.elastic.co/t/histogramfacet-date-oddness/3672 "2010-12-16T18:14:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rich\_Kroll](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rich_kroll/32/3229_2.png) [@Rich\_Kroll](https://discuss.elastic.co/u/Rich_Kroll)\
**Post date:** [December 16, 2010, 6:14pm UTC](https://discuss.elastic.co/t/histogramfacet-date-oddness/3672/1 "2010-12-16T18:14:10Z")

</div>

Hey all,  
I have ran into an oddity when working with the HistogramFacet and hoped  
someone could point me in the direction of what i'm doing wrong. The  
problem relates to the time\_interval of the Histogram facet, and if I try to  
bucked on a day (24h), my dates are shifting backwards a day.

The following gist exemplifies the problem:

> <https://gist.github.com/rkroll/743752>

Thanks for the help!

--  
“We can't solve problems by using the same kind of thinking we used when we  
created them.” ~ Albert Einstein

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 19, 2010, 2:58am UTC](https://discuss.elastic.co/t/histogramfacet-date-oddness/3672/2 "2010-12-19T02:58:20Z")

</div>

Heya,

It seems like its working for me. Note, all times stored in ES are UTC  
based, and when stating things like 24h interval in the histogram facet it  
will be computed based on the UTC based values. Here is, for example, what I  
get for both values:

2010-12-13T00:00:00.000Z from 2010-12-13T17:21:09.000Z  
2010-12-16T00:00:00.000Z from 2010-12-16T17:21:09.000Z

The first value is the UTC based value of the histogram facet, and the  
second is the value provided when indexing. You can see that they fall into  
the correct buckets.

There was a thread a few days ago suggesting that the histogram facet (or  
maybe a specialized date histogram facet), should allow to provide the  
timezones to work with, since the main computations are done on the facet  
itself, and it make sense to want it in a day interval, but with a different  
timezone.

-shay.banon

On Thu, Dec 16, 2010 at 8:14 PM, Rich Kroll [kroll.rich@gmail.com](mailto:kroll.rich@gmail.com) wrote:

> Hey all,  
> I have ran into an oddity when working with the HistogramFacet and hoped  
> someone could point me in the direction of what i'm doing wrong. The  
> problem relates to the time\_interval of the Histogram facet, and if I try to  
> bucked on a day (24h), my dates are shifting backwards a day.
> 
> The following gist exemplifies the problem:
> 
> [Displays the histogram oddness on dates · GitHub](https://gist.github.com/743752)
> 
> Thanks for the help!
> 
> --  
> “We can't solve problems by using the same kind of thinking we used when we  
> created them.” ~ Albert Einstein

---

<div class="post-metadata">

**Author:** ![Rich\_Kroll](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rich_kroll/32/3229_2.png) [@Rich\_Kroll](https://discuss.elastic.co/u/Rich_Kroll)\
**Post date:** [December 19, 2010, 2:07pm UTC](https://discuss.elastic.co/t/histogramfacet-date-oddness/3672/3 "2010-12-19T14:07:08Z")

</div>

Shay,  
Thanks for following up. I ran my gist example again and this time output  
the times in UTC, and discovered why this behaved strangely for me. When  
bucketing the results with 12h, the time portion of the date is set to  
12:00:00+00:00,  
and when output in EST will still be on the same "day". When using the 24h  
interval the time is set to 00:00:00+00:00 which when converted to EST will  
display as the previous "day".

A specialized date range facet which allowed configuration of the timezone  
would be a huge benefit in my use case.

Again,  
Thanks for lending a hand!

On Sat, Dec 18, 2010 at 9:58 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> Heya,
> 
> It seems like its working for me. Note, all times stored in ES are UTC  
> based, and when stating things like 24h interval in the histogram facet it  
> will be computed based on the UTC based values. Here is, for example, what I  
> get for both values:
> 
> 2010-12-13T00:00:00.000Z from 2010-12-13T17:21:09.000Z  
> 2010-12-16T00:00:00.000Z from 2010-12-16T17:21:09.000Z
> 
> The first value is the UTC based value of the histogram facet, and the  
> second is the value provided when indexing. You can see that they fall into  
> the correct buckets.
> 
> There was a thread a few days ago suggesting that the histogram facet  
> (or maybe a specialized date histogram facet), should allow to provide the  
> timezones to work with, since the main computations are done on the facet  
> itself, and it make sense to want it in a day interval, but with a different  
> timezone.
> 
> -shay.banon

--  
“We can't solve problems by using the same kind of thinking we used when we  
created them.” ~ Albert Einstein

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 19, 2010, 5:27pm UTC](https://discuss.elastic.co/t/histogramfacet-date-oddness/3672/4 "2010-12-19T17:27:33Z")

</div>

Great :), so one issue/feature instead of possible two, I call it a good day  
:). Can you open a feature request for that? I plan to revisit facets and do  
some refactoring there, and once its done, I can implement things like  
date\_interval facet.

On Sun, Dec 19, 2010 at 4:07 PM, Rich Kroll [kroll.rich@gmail.com](mailto:kroll.rich@gmail.com) wrote:

> Shay,  
> Thanks for following up. I ran my gist example again and this time output  
> the times in UTC, and discovered why this behaved strangely for me. When  
> bucketing the results with 12h, the time portion of the date is set to 12:00:00+00:00,  
> and when output in EST will still be on the same "day". When using the 24h  
> interval the time is set to 00:00:00+00:00 which when converted to EST will  
> display as the previous "day".
> 
> A specialized date range facet which allowed configuration of the timezone  
> would be a huge benefit in my use case.
> 
> Again,  
> Thanks for lending a hand!
> 
> On Sat, Dec 18, 2010 at 9:58 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:
> 
> > Heya,
> > 
> > It seems like its working for me. Note, all times stored in ES are UTC  
> > based, and when stating things like 24h interval in the histogram facet it  
> > will be computed based on the UTC based values. Here is, for example, what I  
> > get for both values:
> > 
> > 2010-12-13T00:00:00.000Z from 2010-12-13T17:21:09.000Z  
> > 2010-12-16T00:00:00.000Z from 2010-12-16T17:21:09.000Z
> > 
> > The first value is the UTC based value of the histogram facet, and the  
> > second is the value provided when indexing. You can see that they fall into  
> > the correct buckets.
> > 
> > There was a thread a few days ago suggesting that the histogram facet  
> > (or maybe a specialized date histogram facet), should allow to provide the  
> > timezones to work with, since the main computations are done on the facet  
> > itself, and it make sense to want it in a day interval, but with a different  
> > timezone.
> > 
> > -shay.banon
> 
> --  
> “We can't solve problems by using the same kind of thinking we used when we  
> created them.” ~ Albert Einstein

---

<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:** [July 6, 2017, 4:15am UTC](https://discuss.elastic.co/t/histogramfacet-date-oddness/3672/5 "2017-07-06T04:15:09Z")

</div>


