# Aggregate return negative value for min timestamp

**URL:** <https://discuss.elastic.co/t/aggregate-return-negative-value-for-min-timestamp/223157>\
**Category:** Elasticsearch\
**Created:** [March 11, 2020, 2:25pm UTC](https://discuss.elastic.co/t/aggregate-return-negative-value-for-min-timestamp/223157 "2020-03-11T14:25:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ameed\_Ashour](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ameed_ashour/32/45171_2.png) [@Ameed\_Ashour](https://discuss.elastic.co/u/Ameed_Ashour)\
**Post date:** [March 11, 2020, 2:25pm UTC](https://discuss.elastic.co/t/aggregate-return-negative-value-for-min-timestamp/223157/1 "2020-03-11T14:25:52Z")

</div>

Hi,

I am working with ES Version: 6.2.1,

I tried to get the minimum and maximum timestamp to use it for Kibana,

POST/ :9200/{Index\_name}/\_search  
{  
"size": 0,  
"aggregations": {  
"minimum\_date": {  
"min": {  
"field": "@timestamp",  
"format": "yyyy-MM-dd"  
}  
},  
"maximum\_date": {  
"max": {  
"field": "@timestamp",  
"format": "yyyy-MM-dd"  
}  
}  
}  
}

sometimes I got negative value for minimum field as follow:

"aggregations": {  
"maximum\_date": {  
"value": 1.581335308306E12,  
"value\_as\_string": "2020-02-10"  
},  
"minimum\_date": {  
**"value": -6.2163962183E13,**  
"value\_as\_string": "0000-02-07"  
}  
}

Thanks in advance!

---

<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:** [March 12, 2020, 10:42am UTC](https://discuss.elastic.co/t/aggregate-return-negative-value-for-min-timestamp/223157/2 "2020-03-12T10:42:20Z")

</div>

Dates are stored as milliseconds since the epoch, which means a value of `0` is midnight in 1970. As your min date is around the year zero, it is negative.

--Alex

---

<div class="post-metadata">

**Author:** ![Ameed\_Ashour](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ameed_ashour/32/45171_2.png) [@Ameed\_Ashour](https://discuss.elastic.co/u/Ameed_Ashour)\
**Post date:** [March 15, 2020, 7:30am UTC](https://discuss.elastic.co/t/aggregate-return-negative-value-for-min-timestamp/223157/3 "2020-03-15T07:30:41Z")

</div>

Hi Alex,

Thanks for reply,  
I found that I store some field with year = 0000 (i.e 0000-03-15 12:00:00) so that appears in negative as you mentioned.

Best Regards  
Ameed

---

<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 12, 2020, 7:30am UTC](https://discuss.elastic.co/t/aggregate-return-negative-value-for-min-timestamp/223157/4 "2020-04-12T07:30:55Z")

</div>

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