# Aggregate max against date field returns unformatted date

**URL:** <https://discuss.elastic.co/t/aggregate-max-against-date-field-returns-unformatted-date/19374>\
**Category:** Elasticsearch\
**Created:** [August 20, 2014, 6:56pm UTC](https://discuss.elastic.co/t/aggregate-max-against-date-field-returns-unformatted-date/19374 "2014-08-20T18:56:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kti\_sk](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@kti\_sk](https://discuss.elastic.co/u/kti_sk)\
**Post date:** [August 20, 2014, 6:56pm UTC](https://discuss.elastic.co/t/aggregate-max-against-date-field-returns-unformatted-date/19374/1 "2014-08-20T18:56:28Z")

</div>

queries such as  
{  
"aggs": {  
"max\_startTime": {  
"max": {  
"field": "startDate"  
}  
},  
"min\_startTime": {  
"min": {  
"field": "startDate"  
}  
}  
}  
}

return s140834239392... instead of nicely formatted date.  
The field is maked as date type.  
Am I using the query wrong? is there a way to 'cast' the data to date?

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/f5555dc5-1ca9-4140-b828-770389f38691%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f5555dc5-1ca9-4140-b828-770389f38691%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [August 22, 2014, 11:25pm UTC](https://discuss.elastic.co/t/aggregate-max-against-date-field-returns-unformatted-date/19374/2 "2014-08-22T23:25:40Z")

</div>

You are doing things right, it is just that the max aggregation doesn't  
support this feature.

On Wed, Aug 20, 2014 at 8:56 PM, [kti\_sk@hotmail.com](mailto:kti_sk@hotmail.com) wrote:

> queries such as  
> {  
> "aggs": {  
> "max\_startTime": {  
> "max": {  
> "field": "startDate"  
> }  
> },  
> "min\_startTime": {  
> "min": {  
> "field": "startDate"  
> }  
> }  
> }  
> }
> 
> return s140834239392... instead of nicely formatted date.  
> The field is maked as date type.  
> Am I using the query wrong? is there a way to 'cast' the data to date?
> 
> 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/f5555dc5-1ca9-4140-b828-770389f38691%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f5555dc5-1ca9-4140-b828-770389f38691%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/f5555dc5-1ca9-4140-b828-770389f38691%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/f5555dc5-1ca9-4140-b828-770389f38691%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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/CAL6Z4j79zd9B9QeVMcED2Xay4\_Mx7DLuz0w2y%3DL-YcTxBJsOQg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j79zd9B9QeVMcED2Xay4_Mx7DLuz0w2y%3DL-YcTxBJsOQg%40mail.gmail.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:06am UTC](https://discuss.elastic.co/t/aggregate-max-against-date-field-returns-unformatted-date/19374/3 "2017-07-06T01:06:53Z")

</div>


