I am trying to change the format of date and time using pipeline but doesn't work

Here is the pipeline :

PUT _ingest/pipeline/dateformat
{
"description" : "To change Date format",
"processors" : [
{
"date" : {
"field" : "EndDate",
"target_field" : "newEndDate",
"formats" : ["date_time"]
}
}
]
}

I tried to simulate and get this error

POST _ingest/pipeline/dateformat/_simulate
{
"docs":[
{
"_source":{
"EndDate":"2021-05-31 00:00:00"
}
}
]
}

{
"docs" : [
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "unable to parse date [2021-05-31 00:00:00]"
}
],
"type" : "illegal_argument_exception",
"reason" : "unable to parse date [2021-05-31 00:00:00]",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "failed to parse date field [2021-05-31 00:00:00] with format [date_time]",
"caused_by" : {
"type" : "date_time_parse_exception",
"reason" : "Failed to parse with all enclosed parsers"
}
}
}
}
]
}

I am not sure what's happening here, the reason of this pipeline is to change the date format right ?

And also please suggest me any way to change the date format

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

The documentation says that date_time is

A formatter that combines a full date and time, separated by a T : yyyy-MM-dd'T'HH:mm:ss.SSSZZ.

Here 2021-05-31 00:00:00 does not match this pattern.

Try with: "formats" : ["yyyy-MM-dd HH:mm:ss"] instead.

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