# How to clean field which contains a date value

**URL:** <https://discuss.elastic.co/t/how-to-clean-field-which-contains-a-date-value/175988>\
**Category:** Elasticsearch\
**Created:** [April 9, 2019, 8:57am UTC](https://discuss.elastic.co/t/how-to-clean-field-which-contains-a-date-value/175988 "2019-04-09T08:57:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsam](https://avatars.discourse-cdn.com/v4/letter/n/ecd19e/32.png) [@nsam](https://discuss.elastic.co/u/nsam)\
**Post date:** [April 9, 2019, 8:57am UTC](https://discuss.elastic.co/t/how-to-clean-field-which-contains-a-date-value/175988/1 "2019-04-09T08:57:20Z")

</div>

I have documents like

```
{
 "mydate" : "\/Date(1553767871903)\/",
 "myvalue" : 100
}

```

in field _mydate_, date exists in epoch\_second (/Date(_1553767871903_)/).  
How can I clean up the characters I dont need and set field mydate to "format" : "date" during indexing process. Lastly I need mydate to draw a Data Histogramm in Kibana.

regards

---

<div class="post-metadata">

**Author:** ![nsam](https://avatars.discourse-cdn.com/v4/letter/n/ecd19e/32.png) [@nsam](https://discuss.elastic.co/u/nsam)\
**Post date:** [April 13, 2019, 7:23am UTC](https://discuss.elastic.co/t/how-to-clean-field-which-contains-a-date-value/175988/2 "2019-04-13T07:23:59Z")

</div>

This here at least lead to the desired result.  
However, now I have a further field named "mydate"

```
POST _ingest/pipeline/_simulate
{
    "pipeline": { 
    "description": "cork_pipeline",
    "processors": [
      {
      "grok": {
        "field": "date",
        "patterns": ["(?<mydate>[0-9]+)"]
      }
        }
    ]
  },
  "docs" : [{
    "_source": {
    "date": "\/Date(1553767771903)\/"
   }
  }]
}

```

Respond

```
{
  "docs": [
    {
      "doc": {
        "_index": "_index",
        "_type": "_type",
        "_id": "_id",
        "_source": {
          "date": "/Date(1553767771903)/",
          "mydate": "1553767771903"
        },
        "_ingest": {
          "timestamp": "2019-04-09T13:40:38.753Z"
        }
      }
    }
  ]
}
```

---

<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:** [May 11, 2019, 7:24am UTC](https://discuss.elastic.co/t/how-to-clean-field-which-contains-a-date-value/175988/3 "2019-05-11T07:24:06Z")

</div>

Closed on May 11, 2019, 7:24am UTC

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