# Ingest pipeline add field with date in the future

**URL:** https://discuss.elastic.co/t/ingest-pipeline-add-field-with-date-in-the-future/277489
**Category:** Elasticsearch
**Tags:** ingest-pipeline
**Created:** [June 30, 2021, 5:20pm UTC](https://discuss.elastic.co/t/ingest-pipeline-add-field-with-date-in-the-future/277489 "2021-06-30T17:20:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sam3546](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sam3546/32/79281_2.png) [@sam3546](https://discuss.elastic.co/u/sam3546)
#### Post date: [June 30, 2021, 5:20pm UTC](https://discuss.elastic.co/t/ingest-pipeline-add-field-with-date-in-the-future/277489/1 "2021-06-30T17:20:22Z")

</div>

Via an ingest pipeline using a processor such as a script (similar to [this](https://discuss.elastic.co/t/how-to-calculate-date-diffs-using-ingest-node/169652)) or another processor is it simple to add a field with the date x days (a field on the ingested doc) after its ingested.

Such that a doc

```auto
field: somedata
SLA: 14

```

has a field 'overdue' that is the date x days (in this example 14) from when its ingested

```auto
field: somedata
SLA: 14
overdue: x/x/21

```

Cheers

---

<div class="post-metadata">

### Author: ![sam3546](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sam3546/32/79281_2.png) [@sam3546](https://discuss.elastic.co/u/sam3546)
#### Post date: [July 1, 2021, 2:08pm UTC](https://discuss.elastic.co/t/ingest-pipeline-add-field-with-date-in-the-future/277489/2 "2021-07-01T14:08:59Z")

</div>

So replying to my own question again, Not tested but through digging around this is likely to be possible via the use of a script processor.

Get the field convert to millis, Instant, ZTD, then on that ZTD object a function .plusHours(x) or plusDays(x) etc ctx.SLA = ZTD object then set it as a field with the set processor.

Im sure this can be made more efficient but as a baseline this should achieve the result.

Cheers me.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [July 1, 2021, 2:11pm UTC](https://discuss.elastic.co/t/ingest-pipeline-add-field-with-date-in-the-future/277489/3 "2021-07-01T14:11:16Z")

</div>

This looks correct. Depending on the type of time stamp you could go with `ZonedDateTime.parse` directly or have your own custom date formatter, that can also be used to write out the date as a string again.

---

<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 29, 2021, 2:11pm UTC](https://discuss.elastic.co/t/ingest-pipeline-add-field-with-date-in-the-future/277489/4 "2021-07-29T14:11:24Z")

</div>

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