I have created an index with "TimeStamp" field which has date and time data in standard ISO format "YYYY-MM-DD HH:MM:SS+00:00". I have a requirement of filtering data that falls between specific time on a given day. For example, I want to filter data that was collected between 6am and 12:30 pm on all days of January month of 2019. I used the script tag to filter by hours and it works. But I am not able to figure out how to add minutes to the equation. Here is what my query currently looks like
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"range": {
"TimeStamp": {
"gte": "2019-01-01T00:00:00.000Z",
"lte": "2019-01-31T23:59:59.000Z"
}
}
},
{
"script": {
"script": {
"source": "(doc['TimeStamp'].value.getHour() >= 6 && doc['TimeStamp'].value.getHour() <= 22)"
}
}
}
]
}
}
}
}
}
This gives me data for specific hours, but how do I add minutes to this? Adding getMinute() actually applies it separately and filters out relevant results. Could anyone please guide me with this?