# Parse rfc 2822 date string to timestamp using update by query

**URL:** <https://discuss.elastic.co/t/parse-rfc-2822-date-string-to-timestamp-using-update-by-query/189970>\
**Category:** Elasticsearch\
**Created:** [July 11, 2019, 10:15am UTC](https://discuss.elastic.co/t/parse-rfc-2822-date-string-to-timestamp-using-update-by-query/189970 "2019-07-11T10:15:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alberto\_Ciolini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alberto_ciolini/32/47533_2.png) [@Alberto\_Ciolini](https://discuss.elastic.co/u/Alberto_Ciolini)\
**Post date:** [July 11, 2019, 10:15am UTC](https://discuss.elastic.co/t/parse-rfc-2822-date-string-to-timestamp-using-update-by-query/189970/1 "2019-07-11T10:15:53Z")

</div>

Hi everyone,  
I've a bunch of documents inside an index with a string field, _created\_at_, that represents a date in rfc 2822 format (ex.: _Thu, 17 Oct 2013 16:09:44 +0000_). I've another date field, _created\_at\_time_, and I'd like to know if it possibile parse _create\_at_ field in date format using script field in **update\_by\_query**.

Thank you.

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [July 19, 2019, 4:57pm UTC](https://discuss.elastic.co/t/parse-rfc-2822-date-string-to-timestamp-using-update-by-query/189970/2 "2019-07-19T16:57:08Z")

</div>

Yes, this is possible. Depending on the version of ES you are using, you should be able to parse this with `DateTimeFormatter.RFC_1123_DATE_TIME`, and then use the returned TemporalAccessor from parsing to extract time or whatever else you want to store separately.

Note that for update by query, you probably want to check whether the field you are adding has already been added, so that you can "resume" (by making the update a noop) if there is any issue while running your query. The [update by query docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html) should help explain this more.

---

<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:** [August 16, 2019, 4:57pm UTC](https://discuss.elastic.co/t/parse-rfc-2822-date-string-to-timestamp-using-update-by-query/189970/3 "2019-08-16T16:57:17Z")

</div>

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