# GTE epoch brings results but GTE now-1d/d doesn't

**URL:** <https://discuss.elastic.co/t/gte-epoch-brings-results-but-gte-now-1d-d-doesnt/171917>\
**Category:** Elasticsearch\
**Created:** [March 12, 2019, 10:11am UTC](https://discuss.elastic.co/t/gte-epoch-brings-results-but-gte-now-1d-d-doesnt/171917 "2019-03-12T10:11:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [March 12, 2019, 10:11am UTC](https://discuss.elastic.co/t/gte-epoch-brings-results-but-gte-now-1d-d-doesnt/171917/1 "2019-03-12T10:11:36Z")

</div>

We have a rollup index with data timestamped to midnight of each day. So today we have data timestamped to midnight yesterday `2019-03-11T00:00:00.00000` CET.

We want to build a visualisation which always shows yesterday's data and thus we want to use `now-1d/d` in the query.

When we query the data with the epoch `1552258800000` (Monday, March 11, 2019 12:00:00 AM) we get results:

```auto
"range": {
    "timestamp.date_histogram.timestamp": {
        "gte": 1552258800000,
        "format": "epoch_millis"
    }
}

```

However, using relative dates back to yesterday midnight `now-1d/d` brings no results:

```auto
"range": {
    "timestamp.date_histogram.timestamp": {
     "gte": "now-1d/d",
     "lte": "now"
    }
}

```

Our data (returned in the first example with `epoch_millis`) has the following timestamp:

```auto
"timestamp.date_histogram.timestamp": 1552258800000,

```

Interestingly using Kibana the relative query does work and we get the data we want:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/e/beb45d870288ecb00750ed07346e8657b7db8520.png)

Of course, kibana doesn't use `now-1d/d` but `gte: 1552258800000` so that's kinda frustrating...

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [March 12, 2019, 10:31am UTC](https://discuss.elastic.co/t/gte-epoch-brings-results-but-gte-now-1d-d-doesnt/171917/2 "2019-03-12T10:31:19Z")

</div>

Trial and error leads me to conclude that yesterday midnight is not `now-1d/d` but `now-2d/d`.

I'd always assumed rounding by day meant rounding down (as Kibana does) but this is obviously rounding up.

---

<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:** [April 9, 2019, 10:31am UTC](https://discuss.elastic.co/t/gte-epoch-brings-results-but-gte-now-1d-d-doesnt/171917/3 "2019-04-09T10:31:30Z")

</div>

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