# Scripted field containing timestamp less 1 hour

**URL:** <https://discuss.elastic.co/t/scripted-field-containing-timestamp-less-1-hour/131351>\
**Category:** Kibana\
**Created:** [May 10, 2018, 7:56pm UTC](https://discuss.elastic.co/t/scripted-field-containing-timestamp-less-1-hour/131351 "2018-05-10T19:56:23Z")\
**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 10, 2018, 7:56pm UTC](https://discuss.elastic.co/t/scripted-field-containing-timestamp-less-1-hour/131351/1 "2018-05-10T19:56:23Z")

</div>

Hello -

I would like to create a scripted field that takes my existing timestamp field and subtracts 1 hour.

What I have is:

timestamp\_OMi  
Language: painless  
Type: date  
Format: Date  
Script: doc['@timestamp'].value - 3600000

When this is in place I receive a "Courier Fetch... shards failed" error.

Thanks for your help,  
Butch

---

<div class="post-metadata">

**Author:** ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)\
**Post date:** [May 10, 2018, 8:07pm UTC](https://discuss.elastic.co/t/scripted-field-containing-timestamp-less-1-hour/131351/2 "2018-05-10T20:07:11Z")

</div>

You need to use `.getMillis()` to get the date in milliseconds:

`doc['@timestamp'].value.getMillis() - 3600000`

---

<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 10, 2018, 8:22pm UTC](https://discuss.elastic.co/t/scripted-field-containing-timestamp-less-1-hour/131351/3 "2018-05-10T20:22:53Z")

</div>

That was it! Thank you for your response!

---

<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 7, 2018, 8:33pm UTC](https://discuss.elastic.co/t/scripted-field-containing-timestamp-less-1-hour/131351/4 "2018-06-07T20:33:36Z")

</div>

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