Reputation: 1214
I have the structure as below. I need to write the query to add 30 days from the "expiryDate" then check less than today date.
{
_id: "100000001",
name: "John",
expiryDate: "30/07/2020"
}
Here, I need to check expirtyDate + 30 days < today date
Anyone help me to do the query.
Upvotes: 1
Views: 557
Reputation: 217274
So you want to find the documents whose expiry date are within 30 days of the current date. You need to do it like this:
{
"query": {
"range": {
"expiryDate": {
"gte": "now-30d",
"lte": "now"
}
}
}
}
Upvotes: 2