# Date formatting for import

**URL:** <https://discuss.elastic.co/t/date-formatting-for-import/215063>\
**Category:** Elasticsearch\
**Created:** [January 15, 2020, 2:05am UTC](https://discuss.elastic.co/t/date-formatting-for-import/215063 "2020-01-15T02:05:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dedicatedmanagers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dedicatedmanagers/32/60359_2.png) [@dedicatedmanagers](https://discuss.elastic.co/u/dedicatedmanagers)\
**Post date:** [January 15, 2020, 2:05am UTC](https://discuss.elastic.co/t/date-formatting-for-import/215063/1 "2020-01-15T02:05:06Z")

</div>

I have a date field that is in the following format:  
01-JAN-20

When I map the field to dd-MMM-yy it won't accept the date above but it will accept the following:  
01-Jan-20

Is there a way to get Elasticsearch to accept the former?

```auto
PUT tctestindex
{
  "mappings": {
    "properties": {
      "date": {
        "type": "date", 
        "format": "d-MMM-yy"
      }
    }
  }
}

# works!
PUT tctestindex/_doc/1
{ "date": "01-Jan-20" }

#fails!
PUT tctestindex/_doc/2
{ "date": "01-JAN-20" }

```

---

<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:** [January 15, 2020, 10:45am UTC](https://discuss.elastic.co/t/date-formatting-for-import/215063/2 "2020-01-15T10:45:33Z")

</div>

Hey,

I do not think is possible, after a quick scan of [https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html) (you may want to take a look yourself).

You could maybe convert this using a script processor and some text wranling.

--Alex

---

<div class="post-metadata">

**Author:** ![dedicatedmanagers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dedicatedmanagers/32/60359_2.png) [@dedicatedmanagers](https://discuss.elastic.co/u/dedicatedmanagers)\
**Post date:** [January 15, 2020, 5:31pm UTC](https://discuss.elastic.co/t/date-formatting-for-import/215063/3 "2020-01-15T17:31:34Z")

</div>

@spinscale - thanks for the response. I did see that link and saw this line:  
M/L month-of-year number/text 7; 07; Jul; July; J

I just thought I might be missing something; specifically with what the "L" is for.

---

<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:** [January 20, 2020, 4:02pm UTC](https://discuss.elastic.co/t/date-formatting-for-import/215063/4 "2020-01-20T16:02:55Z")

</div>

the `L` is for the name only, but still requires the first (and only the first) letter to be uppercased from what I understand.

---

<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:** [February 17, 2020, 4:07pm UTC](https://discuss.elastic.co/t/date-formatting-for-import/215063/5 "2020-02-17T16:07:27Z")

</div>

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