# JSON Query 1hr before and 1hr after epoch time

**URL:** <https://discuss.elastic.co/t/json-query-1hr-before-and-1hr-after-epoch-time/131526>\
**Category:** Kibana\
**Created:** [May 11, 2018, 6:14pm UTC](https://discuss.elastic.co/t/json-query-1hr-before-and-1hr-after-epoch-time/131526 "2018-05-11T18:14:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkelley](https://avatars.discourse-cdn.com/v4/letter/b/e9a140/32.png) [@bkelley](https://discuss.elastic.co/u/bkelley)\
**Post date:** [May 11, 2018, 6:14pm UTC](https://discuss.elastic.co/t/json-query-1hr-before-and-1hr-after-epoch-time/131526/1 "2018-05-11T18:14:07Z")

</div>

Hello -

I have an epoch date (in ms) and I'm trying to create a JSON query that gives me all records between 1 hour before and 1 hour after my epoch date.

Below is my query which is not working. Is there a "right" way to do this?

Thanks,  
Butch

{  
"range": {  
"@timestamp": {  
"gt": "1526002896000||-3600000",  
"lt": "1526002896000||+3600000"  
}  
}

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [May 11, 2018, 7:51pm UTC](https://discuss.elastic.co/t/json-query-1hr-before-and-1hr-after-epoch-time/131526/2 "2018-05-11T19:51:59Z")

</div>

Hey, I think that's pretty much it but you'll want to add units at the end:

```auto
"gt": "1526002896000||-1h",
"lt": "1526002896000||+1h"

```

Are you getting any errors?

---

<div class="post-metadata">

**Author:** ![bkelley](https://avatars.discourse-cdn.com/v4/letter/b/e9a140/32.png) [@bkelley](https://discuss.elastic.co/u/bkelley)\
**Post date:** [May 14, 2018, 12:56pm UTC](https://discuss.elastic.co/t/json-query-1hr-before-and-1hr-after-epoch-time/131526/3 "2018-05-14T12:56:22Z")

</div>

Thanks Jon - that worked!

---

<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 11, 2018, 12:56pm UTC](https://discuss.elastic.co/t/json-query-1hr-before-and-1hr-after-epoch-time/131526/4 "2018-06-11T12:56:25Z")

</div>

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