# 'year' long (2,019) to 'year\_alias' ('2019-01-01')

**URL:** <https://discuss.elastic.co/t/year-long-2-019-to-year-alias-2019-01-01/171204>\
**Category:** Elasticsearch\
**Created:** [March 6, 2019, 8:48pm UTC](https://discuss.elastic.co/t/year-long-2-019-to-year-alias-2019-01-01/171204 "2019-03-06T20:48:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_J](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_j/32/40696_2.png) [@Joe\_J](https://discuss.elastic.co/u/Joe_J)\
**Post date:** [March 6, 2019, 8:48pm UTC](https://discuss.elastic.co/t/year-long-2-019-to-year-alias-2019-01-01/171204/1 "2019-03-06T20:48:47Z")

</div>

Field 'year' automapped to long ("2019" --\> "2,019")

How to convert, script, alias, painless, whatever into a field that acts as a proper year?

I tried a scripted field with:  
new SimpleDateFormat('yyyy-MM-dd').parse(doc['year'].value + "-01-01").getTime();

It seems to work -- any better ideas than doing this?

---

<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 3, 2019, 8:48pm UTC](https://discuss.elastic.co/t/year-long-2-019-to-year-alias-2019-01-01/171204/2 "2019-04-03T20:48:50Z")

</div>

Closed on April 3, 2019, 8:48pm UTC

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