Aggregate return negative value for min timestamp

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!

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

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