Generate date time string automatically

Hi,
I am using Kibana and DSL query. I am searching a range of dates which should be set when I am running the query. For example - setting one date field with the current date and another 6 days earlier than the current date, all in the same JSON. In the following snippet the dates should be according the execution date and not "hard coded".

{
    "range": {
        "customs_statuses.date_time": {
            "gte": "2024-03-14",
            "lte": "2024-03-20"
        }
    }
}

Thanks

Hello @elichai, welcome to the community!

You can use date math, if I understood correctly, something like this:

{
  "range": {
    "customs_statuses.date_time": {
      "gte": "now-6d/d",
      "lte": "now/d"
    }
  }
}
1 Like

Great. Thanks for the prompt answer.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.