# How to get results with a timestamp greater than a certain date

**URL:** <https://discuss.elastic.co/t/how-to-get-results-with-a-timestamp-greater-than-a-certain-date/87269>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [May 26, 2017, 3:00pm UTC](https://discuss.elastic.co/t/how-to-get-results-with-a-timestamp-greater-than-a-certain-date/87269 "2017-05-26T15:00:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prodrg](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@prodrg](https://discuss.elastic.co/u/prodrg)\
**Post date:** [May 26, 2017, 3:00pm UTC](https://discuss.elastic.co/t/how-to-get-results-with-a-timestamp-greater-than-a-certain-date/87269/1 "2017-05-26T15:00:25Z")

</div>

Hello guys, I need to set a Watcher to look for results of a certain query. I need the results from the last 5 minutes (generally, it returns all the results from the index if I don't specify a filter). This is the Watcher code:

```
{
  "trigger" : {
    "schedule" : {
      "interval" : "5m"
    }
  },
  "input" : {
    "search" : {
      "request" : {
        "indices" : ["<logstash-{now/d}>"],
        "types" : ["vectra"],
        "body" : {
          "sort" : {
            "@timestamp" : {"order" : "desc"}
          },
          "query" : { 
            "bool" : {
              "must" : [
                { "match" : { "leverage_type" : "Sweeper" }}
              ],
              "filter" : [
                { "range" : { "@timestamp" : { "gte" : "<{now-5m}>"}}}
              ]
            } 
          }
        }
      }
    }
  },
  "condition" : {
    "compare" : {
      "ctx.payload.hits.total" : {
        "gt" : 0
      }
    }
  },
  "actions" : {
    "notify-slack" : {
      "throttle_period" : "5m",
      "slack" : {
        "account" : "testing",
        "message" : {
          "to" : ["@tester"],
          "text" : "{{ctx.payload.hits.total}} Vectra entries found"
        }
      }
    }
  }
}

```

And I'm receiving the following error:  
`SearchPhaseExecutionException[all shards failed]; nested: ElasticsearchParseException[failed to parse date field [<{now-5m}>] with format [strict_date_optional_time||epoch_millis]]; nested: IllegalArgumentException[Parse failure at index [0] of [<{now-5m}>]];`

How can I do a filter for the results that are newer than a certain date and time?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 29, 2017, 11:07am UTC](https://discuss.elastic.co/t/how-to-get-results-with-a-timestamp-greater-than-a-certain-date/87269/2 "2017-05-29T11:07:19Z")

</div>

Hey,

lets take a look at your query

> [@prodrg](#):
>
> "filter" : [  
> { "range" : { "@timestamp" : { "gte" : "\<{now-5m}\>"}}}  
> ]

You used the same syntax as for date index math here (which is admittantly confusing). Can you try just "now-5m" here instead?

--Alex

---

<div class="post-metadata">

**Author:** ![prodrg](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@prodrg](https://discuss.elastic.co/u/prodrg)\
**Post date:** [May 29, 2017, 2:01pm UTC](https://discuss.elastic.co/t/how-to-get-results-with-a-timestamp-greater-than-a-certain-date/87269/3 "2017-05-29T14:01:07Z")

</div>

Yeah, this was completely the issue. I got confused with the usage of \<{}\>.

Thanks for the support

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 26, 2017, 2:01pm UTC](https://discuss.elastic.co/t/how-to-get-results-with-a-timestamp-greater-than-a-certain-date/87269/4 "2017-06-26T14:01:09Z")

</div>

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