# Elasticsearch aggregation over timestamp

**URL:** <https://discuss.elastic.co/t/elasticsearch-aggregation-over-timestamp/35440>\
**Category:** Elasticsearch\
**Created:** [November 24, 2015, 11:34am UTC](https://discuss.elastic.co/t/elasticsearch-aggregation-over-timestamp/35440 "2015-11-24T11:34:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![91pavan](https://avatars.discourse-cdn.com/v4/letter/9/b487fb/32.png) [@91pavan](https://discuss.elastic.co/u/91pavan)\
**Post date:** [November 24, 2015, 11:34am UTC](https://discuss.elastic.co/t/elasticsearch-aggregation-over-timestamp/35440/1 "2015-11-24T11:34:55Z")

</div>

I'm having the following document(s) in ElasticSearch:

```
"ipAddress": "192.168.10.12", "timestamp": "25 Oct 2015 20:00:00", "switchovers": 2

"ipAddress": "192.168.10.12", "timestamp": "26 Oct 2015 20:00:00", "switchovers": 1

```

How can I write an elasticsearch aggregation to find out switchovers[today] - switchovers[yesterday] grouped by IP address?

This is where i'm at:

```
{
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
  "switchover_count_over_time": {
    "terms": {
      "field": "ipAddress"
    },
  }
}
}'

```

Yet to figure out how to extract switchovers for each date (from oct. for example) and compute the difference from the previous day's switchover value..

Any help?

---

<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 5, 2017, 11:36pm UTC](https://discuss.elastic.co/t/elasticsearch-aggregation-over-timestamp/35440/2 "2017-07-05T23:36:19Z")

</div>


