# Create day-of-week and hour-of-day fields from date field during indexing

**URL:** https://discuss.elastic.co/t/create-day-of-week-and-hour-of-day-fields-from-date-field-during-indexing/165418
**Category:** Elasticsearch
**Created:** [January 23, 2019, 1:33pm UTC](https://discuss.elastic.co/t/create-day-of-week-and-hour-of-day-fields-from-date-field-during-indexing/165418 "2019-01-23T13:33:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nili1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@nili1](https://discuss.elastic.co/u/nili1)
#### Post date: [January 23, 2019, 1:33pm UTC](https://discuss.elastic.co/t/create-day-of-week-and-hour-of-day-fields-from-date-field-during-indexing/165418/1 "2019-01-23T13:33:59Z")

</div>

Our data contains a timestamp that is mapped to a date type and has format yyyy-MM-ddTHH:mm:ssZ (e.g. 2019-01-20T18:00:53Z).  
We would like to change it to a multi-field containing different properties of the date - day of week and hour of day - so they can be searched directly without using a script at search time.  
Is it possible to extract the day-of-week and hour-of-day during indexing? Can a script be used in the template mapping to create the day-of-week and hour-of-day fields?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 23, 2019, 2:34pm UTC](https://discuss.elastic.co/t/create-day-of-week-and-hour-of-day-fields-from-date-field-during-indexing/165418/2 "2019-01-23T14:34:10Z")

</div>

Have a look at ingest node feature and the script processor.

---

<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: [February 20, 2019, 2:34pm UTC](https://discuss.elastic.co/t/create-day-of-week-and-hour-of-day-fields-from-date-field-during-indexing/165418/3 "2019-02-20T14:34:22Z")

</div>

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