# Date processor - Pipeline

**URL:** <https://discuss.elastic.co/t/date-processor-pipeline/297566>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [February 18, 2022, 7:02am UTC](https://discuss.elastic.co/t/date-processor-pipeline/297566 "2022-02-18T07:02:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![p2w2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/p2w2/32/101956_2.png) [@p2w2](https://discuss.elastic.co/u/p2w2)\
**Post date:** [February 18, 2022, 7:02am UTC](https://discuss.elastic.co/t/date-processor-pipeline/297566/1 "2022-02-18T07:02:39Z")

</div>

Hi guys.  
I'm trying to add the `date` processor to my index and at first it seemed to be working but then I noticed very strange result that I don't understand and can't find anywhere explanation for this behavior.  
I have a field with long-millis timestamps and I want it to be translated into human date string.

So I made such pipeline processor:

```json
PUT _ingest/pipeline/long_to_date_converter
{
  "processors" : [
    {
      "date": {
        "field" : "timestamp",
        "formats": ["epoch_millis"],
        "target_field": "timestamp1"
      }
    }
  ]
}

```

But then I have got this strange result, all my timestamps were converted into same value `2022-01-01T00:00:00.000Z`

If I run the simulate on the pipeline then I get this result:

```auto
{
  "docs" : [
    {
      "doc" : {
        "_index" : "index",
        "_type" : "_doc",
        "_id" : "id",
        "_source" : {
          "timestamp1" : "2022-01-01T00:00:00.000Z",
          "timestamp" : "1581951442000"
        },
        "_ingest" : {
          "timestamp" : "2022-02-18T06:46:18.0853227Z"
        }
      }
    }
  ]
}

```

Can anyone explain why it happens and how can I achieve the right behavior? I'm using ES version 7.10.2

Timestamp I used in the example (1581951442000) in human date string should be `Mon Feb 17 2020 14:57:22`

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [February 19, 2022, 5:02pm UTC](https://discuss.elastic.co/t/date-processor-pipeline/297566/2 "2022-02-19T17:02:17Z")

</div>

Hi @p2w2 Welcome to the community..BTW we are not all guys 🙂

Per the docs [here](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/date-processor.html)

> `formats` yes -  
> An array of the expected date formats. Can be a [java time pattern](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/mapping-date-format.html) or one of the following formats: ISO8601, UNIX, **UNIX\_MS** , or TAI64N.

Looks like you are using the formats that are used for a mapping not the ingest processor, easy to confused AND they should probably be the consistent at some point

```auto
PUT _ingest/pipeline/long_to_date_converter
{
  "processors" : [
    {
      "date": {
        "field" : "timestamp",
        "formats": ["UNIX_MS"], <!--- Correct Format
        "target_field": "timestamp1"
      }
    }
  ]
}

```

```auto
POST _ingest/pipeline/long_to_date_converter/_simulate
{
  "docs": [
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "timestamp": "1581951442000"
      }
    }
  ]
}

```

result

```auto
{
  "docs" : [
    {
      "doc" : {
        "_index" : "index",
        "_type" : "_doc",
        "_id" : "id",
        "_source" : {
          "timestamp1" : "2020-02-17T14:57:22.000Z",
          "timestamp" : "1581951442000"
        },
        "_ingest" : {
          "timestamp" : "2022-02-19T17:00:45.381877547Z"
        }
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![p2w2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/p2w2/32/101956_2.png) [@p2w2](https://discuss.elastic.co/u/p2w2)\
**Post date:** [February 19, 2022, 9:26pm UTC](https://discuss.elastic.co/t/date-processor-pipeline/297566/3 "2022-02-19T21:26:18Z")

</div>

Sorry for the "guys", my bad.  
And thanks for the reply and the documentation reference.  
Feels so stupid for not reading basic guidance. I wonder now where did I copied this `epoch_millis`

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [February 19, 2022, 9:46pm UTC](https://discuss.elastic.co/t/date-processor-pipeline/297566/4 "2022-02-19T21:46:46Z")

</div>

All good. Glad you got it solved. It's what we're here for!

> [@p2w2](#):
>
> epoch\_millis

Is defined as a pattern for a `date` type in the mapping So you probably saw it [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html)

---

<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:** [March 19, 2022, 9:47pm UTC](https://discuss.elastic.co/t/date-processor-pipeline/297566/5 "2022-03-19T21:47:17Z")

</div>

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