# Using date value in script converts to double before evaluation?

**URL:** <https://discuss.elastic.co/t/using-date-value-in-script-converts-to-double-before-evaluation/61537>\
**Category:** Kibana\
**Created:** [September 26, 2016, 8:15pm UTC](https://discuss.elastic.co/t/using-date-value-in-script-converts-to-double-before-evaluation/61537 "2016-09-26T20:15:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffedwards](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@jeffedwards](https://discuss.elastic.co/u/jeffedwards)\
**Post date:** [September 26, 2016, 8:15pm UTC](https://discuss.elastic.co/t/using-date-value-in-script-converts-to-double-before-evaluation/61537/1 "2016-09-26T20:15:27Z")

</div>

I'm listing a bunch of Max @timestamp in a data table under a series of filters, and I'd rather see them as "time since" than the timestamps to more quickly identify potential problems.

Seems like a great use for a script! But when I run a script "DateTime.now() - \_value", either inline or indexed, it throws an error:

`No signature of method: org.joda.time.DateTime.minus() is applicable for argument types: (java.lang.Double) values: [1.474109352E12]`

Whoa! Since when was my epoch\_millis a double? I tried "DateTime.now() - new DateTime(\_value)" and it complains similarly: \_value is a double.

---

<div class="post-metadata">

**Author:** ![jeffedwards](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@jeffedwards](https://discuss.elastic.co/u/jeffedwards)\
**Post date:** [September 28, 2016, 12:46am UTC](https://discuss.elastic.co/t/using-date-value-in-script-converts-to-double-before-evaluation/61537/2 "2016-09-28T00:46:55Z")

</div>

It looks like ES chokes on epoch\_millis-length longs and that's what's causing the value to get turned into a double. For this case I don't need exact milliseconds, so I can use Math.round(\_value) to get a long into this calculation, which will result in 3 digits of precision loss.

Unfortunately `DateTime.now().getMillis()-Math.round(_value)` winds up looking like January 30th, 1970, so I'll have to find a way to fashion it into a duration. Hopefully the inclusion of duration fields and Painless including Java 8's Joda-inspired time library will make this easier soon.

---

<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:** [July 6, 2017, 1:38pm UTC](https://discuss.elastic.co/t/using-date-value-in-script-converts-to-double-before-evaluation/61537/3 "2017-07-06T13:38:02Z")

</div>


