Date aggregation in ES

I am new to elastic search, would someone kind enough to provide me a jason query to search last two months documents based on below data

"_source":{"date":"2016-08-01T10:24:29+0000","clientCode":"xxxx","countryCode":"AU"}

Hi @avinsahlg,

Please, check the range query using date fields documentation.

It would be something like this:

a. Create the document

PUT test/_doc/1
{
  "date": "2019-08-12T10:24:29+0000",
  "clientCode": "xxxx",
  "countryCode": "AU"
}

b. Search for last 2 months:

GET test/_search
{
  "query": {
    "range": {
      "date": {
        "gte": "now/d-2M",
        "lte": "now/d"
      }
    }
  }
}