Reputation: 1840
I'm looking for a way to partially match a date when querying objects.
I store my dates in the Y-m-d H:i:s
format and now, for example, I want to find all blog posts that were created on May 2015 (by using a field named "created_at" for example). How can I do that?
Although this seems to be like something popular to do, I could not find anything with Google.
Upvotes: 0
Views: 1053
Reputation: 7472
You'll need to use a range
filter, this should work:
{
"query": {
"filtered": {
"filter": {
"range": {
"created_at": {
"gte": "2015-05-01 00:00:00"
"lte": "2015-05-01 23:59:59"
}
}
}
}
}
}
Upvotes: 2