# Extract HH:mm:ss from datetime and compare in script field

**URL:** <https://discuss.elastic.co/t/extract-hhss-from-datetime-and-compare-in-script-field/362124>\
**Category:** Elastic Search\
**Created:** [June 27, 2024, 12:19am UTC](https://discuss.elastic.co/t/extract-hhss-from-datetime-and-compare-in-script-field/362124 "2024-06-27T00:19:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkidev](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rkidev](https://discuss.elastic.co/u/rkidev)\
**Post date:** [June 27, 2024, 12:19am UTC](https://discuss.elastic.co/t/extract-hhss-from-datetime-and-compare-in-script-field/362124/1 "2024-06-27T00:19:58Z")

</div>

I want to extract HH:mm:ss(eg. 29/03/2024 18:01:01) from datetime and check if it's \>= '06:00:00' && \<='18:00:00'.  
Is there any way to achieve this while creating scripted field?

---

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [June 27, 2024, 4:14am UTC](https://discuss.elastic.co/t/extract-hhss-from-datetime-and-compare-in-script-field/362124/2 "2024-06-27T04:14:46Z")

</div>

Hi Rakesh, Could you help us with more context and information -

1. From where you trying to extract this information? Parsing from logstash or something else?
2. Is it from Elasticsearch data? If yes could you please provide sample document? Also giving index mapping will be beneficial.

Thanks

---

<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:** [July 25, 2024, 4:15am UTC](https://discuss.elastic.co/t/extract-hhss-from-datetime-and-compare-in-script-field/362124/3 "2024-07-25T04:15:08Z")

</div>

Closed on July 25, 2024, 4:15am UTC

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