# Question about week granularity elasticsearch uses

**URL:** https://discuss.elastic.co/t/question-about-week-granularity-elasticsearch-uses/17693
**Category:** Elasticsearch
**Created:** [May 23, 2014, 12:37pm UTC](https://discuss.elastic.co/t/question-about-week-granularity-elasticsearch-uses/17693 "2014-05-23T12:37:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Thomas\_Bolis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_bolis/32/700_2.png) [@Thomas\_Bolis](https://discuss.elastic.co/u/Thomas_Bolis)
#### Post date: [May 23, 2014, 12:37pm UTC](https://discuss.elastic.co/t/question-about-week-granularity-elasticsearch-uses/17693/1 "2014-05-23T12:37:59Z")

</div>

Hello,

I stepped into a situation where I need to truncate a timestamp field  
truncated to the week, and i want to do it the exact way elasticsearch does  
it in the datehistogram aggregation in order to be able to perform  
comparisons. Does anyone knows how I should perform the truncate to the  
week? I notice that datehistogram returns the beginning of the week  
(MONDAY), is it safe to use the Calendar way as follows?

Calendar cal = Calendar.getInstance();

> cal.setTimeZone(TimeZone.getTimeZone("GMT"));  
> // cal.set(Calendar.DAY\_OF\_WEEK, cal.getFirstDayOfWeek());  
> cal.set(Calendar.DAY\_OF\_WEEK, Calendar.MONDAY);  
> Date time = cal.getTime();  
> System.out.println("time = " + time);

Is the first day of week depends on the Locale in elasticsearch or not?

Thank you

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4d763e87-d1ab-491f-af7e-8a0b4ba71d39%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4d763e87-d1ab-491f-af7e-8a0b4ba71d39%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:27am UTC](https://discuss.elastic.co/t/question-about-week-granularity-elasticsearch-uses/17693/2 "2017-07-06T01:27:25Z")

</div>


