# Min, max dates not formatting?

**URL:** <https://discuss.elastic.co/t/min-max-dates-not-formatting/16882>\
**Category:** Elasticsearch\
**Created:** [April 9, 2014, 2:22am UTC](https://discuss.elastic.co/t/min-max-dates-not-formatting/16882 "2014-04-09T02:22:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Uckun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_uckun/32/1256_2.png) [@Tim\_Uckun](https://discuss.elastic.co/u/Tim_Uckun)\
**Post date:** [April 9, 2014, 2:22am UTC](https://discuss.elastic.co/t/min-max-dates-not-formatting/16882/1 "2014-04-09T02:22:25Z")

</div>

I have a search like this

{  
size: 0,  
query: {  
match\_all: {}  
},  
aggregations: {

```
    min_date: {min: {field: 'time_stamp', format: 'date_time'}},
    max_date: {max: {field: 'time_stamp', format: "yyyy-MM-dd HH:mm"}}

}

```

}

This fails with a parse error. I can only seem to run this query without a  
format and I get a unix timestamp. What can I do to get the timestamp  
formatted properly.

Thanks.

--  
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/CAGuHJrN8ZFNF4aN-qSUawR0m26r3q%2BvLdSAAaYCdeZepzfnTGw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGuHJrN8ZFNF4aN-qSUawR0m26r3q%2BvLdSAAaYCdeZepzfnTGw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 9, 2014, 7:49am UTC](https://discuss.elastic.co/t/min-max-dates-not-formatting/16882/2 "2014-04-09T07:49:13Z")

</div>

Hey,

can you try to use date formats instead of the named identificators like  
date\_time and see if it works? Also, can you check the exception of the  
elasticsearch logs?

--Alex

On Wed, Apr 9, 2014 at 4:22 AM, Tim Uckun [timuckun@gmail.com](mailto:timuckun@gmail.com) wrote:

> I have a search like this
> 
> {  
> size: 0,  
> query: {  
> match\_all: {}  
> },  
> aggregations: {
> 
> ```
> min_date: {min: {field: 'time_stamp', format: 'date_time'}},
> max_date: {max: {field: 'time_stamp', format: "yyyy-MM-dd HH:mm"}}
> 
> }
> 
> ```
> 
> }
> 
> This fails with a parse error. I can only seem to run this query without a  
> format and I get a unix timestamp. What can I do to get the timestamp  
> formatted properly.
> 
> Thanks.
> 
> --  
> 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/CAGuHJrN8ZFNF4aN-qSUawR0m26r3q%2BvLdSAAaYCdeZepzfnTGw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGuHJrN8ZFNF4aN-qSUawR0m26r3q%2BvLdSAAaYCdeZepzfnTGw%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAGuHJrN8ZFNF4aN-qSUawR0m26r3q%2BvLdSAAaYCdeZepzfnTGw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAGuHJrN8ZFNF4aN-qSUawR0m26r3q%2BvLdSAAaYCdeZepzfnTGw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGCwEM9f7BV9qD0b1A4B2Nfe9b9GmV5mDoZ%3DkFHdQ7qQfCyTEg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9f7BV9qD0b1A4B2Nfe9b9GmV5mDoZ%3DkFHdQ7qQfCyTEg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tim\_Uckun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_uckun/32/1256_2.png) [@Tim\_Uckun](https://discuss.elastic.co/u/Tim_Uckun)\
**Post date:** [April 9, 2014, 11:38pm UTC](https://discuss.elastic.co/t/min-max-dates-not-formatting/16882/3 "2014-04-09T23:38:27Z")

</div>

On Wednesday, April 9, 2014 7:49:13 PM UTC+12, Alexander Reelsen wrote:

> Hey,
> 
> can you try to use date formats instead of the named identificators like  
> date\_time and see if it works? Also, can you check the exception of the  
> elasticsearch logs?

I tried the "yyyy-MM-dd .." it gives an exception and doesn't seem to like  
the key "format"

ailed to execute [org.elasticsearch.action.search.SearchRequest@2c5fbec]  
lastShard [true]  
org.elasticsearch.search.SearchParseException: [blah][0]: from[-1],size[0]:  
Parse Failure [Failed to parse source  
[{"size":0,"aggregations":{"min\_date":{"min":{"field":"time\_stamp","format":"HH:mm"}},"max\_date":{"max":{"field":"time\_stamp"}}}}]]  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:634)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:507)  
at  
org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:480)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:252)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:202)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:203)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:186)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:744)  
Caused by: org.elasticsearch.search.SearchParseException: [blah][0]:  
from[-1],size[0]: Parse Failure [Unknown key for a VALUE\_STRING in  
[min\_date]: [format].]  
at  
org.elasticsearch.search.aggregations.metrics.ValuesSourceMetricsAggregatorParser.parse(ValuesSourceMetricsAggregatorParser.java:68)  
at  
org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:114)  
at  
org.elasticsearch.search.aggregations.AggregatorParsers.parseAggregators(AggregatorParsers.java:77)  
at  
org.elasticsearch.search.aggregations.AggregationParseElement.parse(AggregationParseElement.java:60)  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:622)  
... 11 more

> 

--  
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/494f3834-477e-43ce-9ba5-62f51cfcc97b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/494f3834-477e-43ce-9ba5-62f51cfcc97b%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:37am UTC](https://discuss.elastic.co/t/min-max-dates-not-formatting/16882/4 "2017-07-06T01:37:00Z")

</div>


