# Scripted field doc\['@timestamp'\].date.hourOfDay returs nothing

**URL:** <https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685>\
**Category:** Kibana\
**Created:** [October 22, 2019, 3:44pm UTC](https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685 "2019-10-22T15:44:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew22](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@Andrew22](https://discuss.elastic.co/u/Andrew22)\
**Post date:** [October 22, 2019, 3:44pm UTC](https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685/1 "2019-10-22T15:44:03Z")

</div>

Hello all,

I'm trying to get the hours of the day that the message was sent at so I can filter for during work hours in kibana but the doc['@timestamp'].date.hourOfDay that is suggested to use in the painless scripting documentation is not working. any advice would be much appreciated

Regards,

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [October 22, 2019, 3:56pm UTC](https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685/2 "2019-10-22T15:56:07Z")

</div>

This will depend on the context you're running in. It sounds like you are a filter context?

- Filter context example: [https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl-script-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl-script-query.html)
- Aggregation context example: [https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-aggregations-bucket-datehistogram-aggregation.html#\_using\_a\_script\_to\_aggregate\_by\_day\_of\_the\_week](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-aggregations-bucket-datehistogram-aggregation.html#_using_a_script_to_aggregate_by_day_of_the_week)

---

<div class="post-metadata">

**Author:** ![Andrew22](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@Andrew22](https://discuss.elastic.co/u/Andrew22)\
**Post date:** [October 22, 2019, 4:02pm UTC](https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685/3 "2019-10-22T16:02:59Z")

</div>

Hello Wylie thank you for the post,

I am trying to filter out the hours so I will be able to see what happened during the hours people were at work. I am not sure of your question I am new to scripted fields in kibana

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [October 22, 2019, 4:51pm UTC](https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685/4 "2019-10-22T16:51:00Z")

</div>

Yes, please let me know if the examples above help with that. Our documentation for scripted fields is a bit hard to use, but I think that you are close based on the examples I saw.

---

<div class="post-metadata">

**Author:** ![Andrew22](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@Andrew22](https://discuss.elastic.co/u/Andrew22)\
**Post date:** [October 22, 2019, 5:43pm UTC](https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685/5 "2019-10-22T17:43:36Z")

</div>

I still feel very lost after going over the documentation you have supplied unfortunately . I feel like im missing something it doesn't return an error but it also doesn't return a result

---

<div class="post-metadata">

**Author:** ![Andrew22](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@Andrew22](https://discuss.elastic.co/u/Andrew22)\
**Post date:** [October 22, 2019, 6:02pm UTC](https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685/6 "2019-10-22T18:02:58Z")

</div>

the problem seemed to be instead of doc['@timestamp'].date.hourOfDay it is :  
doc['@timestamp'].value.hourOfDay

---

<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:** [November 19, 2019, 6:03pm UTC](https://discuss.elastic.co/t/scripted-field-doc-timestamp-date-hourofday-returs-nothing/204685/7 "2019-11-19T18:03:14Z")

</div>

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