# Converting StringValue to number to be used in a calculation to generate a new metric

**URL:** <https://discuss.elastic.co/t/converting-stringvalue-to-number-to-be-used-in-a-calculation-to-generate-a-new-metric/69463>\
**Category:** Elasticsearch\
**Created:** [December 19, 2016, 2:59pm UTC](https://discuss.elastic.co/t/converting-stringvalue-to-number-to-be-used-in-a-calculation-to-generate-a-new-metric/69463 "2016-12-19T14:59:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris.needle](https://avatars.discourse-cdn.com/v4/letter/c/85f322/32.png) [@chris.needle](https://discuss.elastic.co/u/chris.needle)\
**Post date:** [December 19, 2016, 2:59pm UTC](https://discuss.elastic.co/t/converting-stringvalue-to-number-to-be-used-in-a-calculation-to-generate-a-new-metric/69463/1 "2016-12-19T14:59:48Z")

</div>

Hi All,

I need to take a 'StringValue' and convert it to a number on the fly. the stringvalue in question hold s a EPOCH date.

Once converted I need to take the timestamp value and subtract the above.

The value of the above then needs writing to a new field that I can reference.

I'm aware that scripted fields need to be of type number, but can I use a number stored withing a StringValue to ultimately give the new metric I'm after?

Cheers

Chris.

---

<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:** [January 16, 2017, 2:59pm UTC](https://discuss.elastic.co/t/converting-stringvalue-to-number-to-be-used-in-a-calculation-to-generate-a-new-metric/69463/2 "2017-01-16T14:59:57Z")

</div>

Closed on January 16, 2017, 2:59pm UTC

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