# Script field with Datefield API fails after 7.0.1 update

**URL:** <https://discuss.elastic.co/t/script-field-with-datefield-api-fails-after-7-0-1-update/180256>\
**Category:** Kibana\
**Created:** [May 8, 2019, 9:29pm UTC](https://discuss.elastic.co/t/script-field-with-datefield-api-fails-after-7-0-1-update/180256 "2019-05-08T21:29:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AQ\_Amra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aq_amra/32/42976_2.png) [@AQ\_Amra](https://discuss.elastic.co/u/AQ_Amra)\
**Post date:** [May 8, 2019, 9:29pm UTC](https://discuss.elastic.co/t/script-field-with-datefield-api-fails-after-7-0-1-update/180256/1 "2019-05-08T21:29:52Z")

</div>

Hi,

I was using the datefield API to create an hour of day scriptfield - (doc['date'].date.hourOfDay + 2).

Since upgrading yo 7.0.1 this now fails and i had to delete the field to load items in the discover tab.

Error message below.

Many thanks in advance

Request to Elasticsearch failed: {"error":{"root\_cause":[{"type":"script\_exception","reason":"runtime error","script\_stack":["doc['date'].date.hourOfDay + 2\n\n"," ^---- HERE"],"script":"doc['date'].date.hourOfDay + 2\n\n","lang":"painless"}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"fetch","grouped":true,"failed\_shards":[{"shard":0,"index":"clinic-visit","node":"pz5wkIMWQ0SJrKSrRqi4cg","reason":{"type":"script\_exception","reason":"runtime error","script\_stack":["doc['date'].date.hourOfDay + 2\n\n"," ^---- HERE"],"script":"doc['date'].date.hourOfDay + 2\n\n","lang":"painless","caused\_by":{"type":"illegal\_argument\_exception","reason":"Illegal list shortcut value [date]."}}}]},"status":400}

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [May 9, 2019, 3:21am UTC](https://discuss.elastic.co/t/script-field-with-datefield-api-fails-after-7-0-1-update/180256/2 "2019-05-09T03:21:49Z")

</div>

hi @AQ_Amra

What version did you upgrade from? There has some deprecations wrt. date-scripting in painless in 7.0. See [https://www.elastic.co/guide/en/elasticsearch//reference/current/breaking-changes-7.0.html#\_getdate\_and\_getdates\_removed](https://www.elastic.co/guide/en/elasticsearch//reference/current/breaking-changes-7.0.html#_getdate_and_getdates_removed)

You might just have to change it to access it by `doc['date'].value.` instead of with the getDate() function, as is explained here: [https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-examples.html#modules-scripting-painless-dates](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-examples.html#modules-scripting-painless-dates)

---

<div class="post-metadata">

**Author:** ![AQ\_Amra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aq_amra/32/42976_2.png) [@AQ\_Amra](https://discuss.elastic.co/u/AQ_Amra)\
**Post date:** [May 9, 2019, 6:44am UTC](https://discuss.elastic.co/t/script-field-with-datefield-api-fails-after-7-0-1-update/180256/3 "2019-05-09T06:44:20Z")

</div>

Thank you. i missed that depreciation.

The solution was: doc['date'].value.hour

---

<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 6, 2019, 6:48am UTC](https://discuss.elastic.co/t/script-field-with-datefield-api-fails-after-7-0-1-update/180256/4 "2019-06-06T06:48:45Z")

</div>

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