# Deprecation message: getDate is no longer necessary on date fields

**URL:** <https://discuss.elastic.co/t/deprecation-message-getdate-is-no-longer-necessary-on-date-fields/113611>\
**Category:** Elasticsearch\
**Created:** [December 29, 2017, 8:20pm UTC](https://discuss.elastic.co/t/deprecation-message-getdate-is-no-longer-necessary-on-date-fields/113611 "2017-12-29T20:20:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VickyHarp](https://avatars.discourse-cdn.com/v4/letter/v/48db29/32.png) [@VickyHarp](https://discuss.elastic.co/u/VickyHarp)\
**Post date:** [December 29, 2017, 8:20pm UTC](https://discuss.elastic.co/t/deprecation-message-getdate-is-no-longer-necessary-on-date-fields/113611/1 "2017-12-29T20:20:08Z")

</div>

I am receiving the deprecation message "getDate is no longer necessary on date fields" on the following:

```
POST _scripts/test-date
{
  "script": {
    "lang": "painless",
    "source": "doc['starttime'].date.hourOfDay < params.startHour"
  }
}

GET daterangetest/_search
{
  "query": {
    "script": {
      "script": {
        "id": "test-date",
        "params": {
          "startHour": 10
        }
      }
    }
  }
}

```

However, if I attempt to use any format other than doc['starttime'].date.hourOfDay I receive errors. Is there a better way I should be doing this?

As a follow up: I've been having some difficulty finding examples and documentation of using dates and date\_ranges in Painless scripts. Can anyone suggest some reading?

---

<div class="post-metadata">

**Author:** ![VickyHarp](https://avatars.discourse-cdn.com/v4/letter/v/48db29/32.png) [@VickyHarp](https://discuss.elastic.co/u/VickyHarp)\
**Post date:** [December 29, 2017, 8:24pm UTC](https://discuss.elastic.co/t/deprecation-message-getdate-is-no-longer-necessary-on-date-fields/113611/2 "2017-12-29T20:24:35Z")

</div>

Oof, classic rubber duck debugging - I worked out I should be using .value. instead of .date.

```
POST _scripts/test-date
{
  "script": {
    "lang": "painless",
    "source": "doc['starttime'].value.hourOfDay < params.startHour"
  }
}

```

That said, my original request stands: can you recommend some examples of date and/or date\_range manipulation in Painless?

---

<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 26, 2018, 8:25pm UTC](https://discuss.elastic.co/t/deprecation-message-getdate-is-no-longer-necessary-on-date-fields/113611/3 "2018-01-26T20:25:04Z")

</div>

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