# type":"date\_time\_exception","reason":"Invalid date 'February 29' as '1970' is not a leap year"}

**URL:** https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570
**Category:** Elasticsearch
**Created:** [October 29, 2019, 1:17am UTC](https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570 "2019-10-29T01:17:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![GeoffreyCutaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/geoffreycutaia/32/56742_2.png) [@GeoffreyCutaia](https://discuss.elastic.co/u/GeoffreyCutaia)
#### Post date: [October 29, 2019, 1:17am UTC](https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570/1 "2019-10-29T01:17:15Z")

</div>

Hi,

We have some issues trying to index documents with date fields set on the 29 of February.

Below an example :

```auto
{"type":"mapper_parsing_exception","reason":"failed to parse field [date_updated] of type [date] in document with id 'mydoc_17107'. Preview of field's value: '2008-02-29 00:00:00'","caused_by":{"type":"date_time_exception","reason":"Invalid date 'February 29' as '1970' is not a leap year"}}

```

Mapping :

```auto
    "mappings" : {
      "mydoc" : {
        "properties" : {
          "date_created" : {
            "type" : "date",
            "format" : "YYYY-MM-dd HH:mm:ss"
          },
          "date_indexed" : {
            "type" : "date",
            "format" : "YYYY-MM-dd HH:mm:ss"
          },
          "date_updated" : {
            "type" : "date",
            "format" : "YYYY-MM-dd HH:mm:ss"
          },
         }
       }
    }

```

We can reproduce the issue locally (Elasticsearch 7.4.0 using the official docker image) and on Elastic Cloud (Elasticsearch 7.4.1).

Any idea?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [October 29, 2019, 6:53am UTC](https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570/2 "2019-10-29T06:53:41Z")

</div>

Does it change if you change `YYYY` to `yyyy` in the format string as [in the docs](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/date.html#multiple-date-formats)?

---

<div class="post-metadata">

### Author: ![GeoffreyCutaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/geoffreycutaia/32/56742_2.png) [@GeoffreyCutaia](https://discuss.elastic.co/u/GeoffreyCutaia)
#### Post date: [October 29, 2019, 6:55am UTC](https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570/3 "2019-10-29T06:55:35Z")

</div>

Hi Christian,

I did try but unfortunately it didn't change anything.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [October 29, 2019, 7:46am UTC](https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570/4 "2019-10-29T07:46:54Z")

</div>

@spinscale does this ring a bell?

---

<div class="post-metadata">

### Author: ![GeoffreyCutaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/geoffreycutaia/32/56742_2.png) [@GeoffreyCutaia](https://discuss.elastic.co/u/GeoffreyCutaia)
#### Post date: [October 30, 2019, 1:36am UTC](https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570/5 "2019-10-30T01:36:08Z")

</div>

I have also tried with Elasticseach 7.2.0 (docker) and same issue.

@dadoonet, @spinscale have you seen this before? Could you fix it?

Thanks

---

<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: [October 31, 2019, 12:42pm UTC](https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570/6 "2019-10-31T12:42:30Z")

</div>

Using `YYYY` will not work, as this refers to a week based year.

I tried this on 7.4.0 and it worked just fine,.

```auto
DELETE test

PUT test
{
  "mappings": {
    "properties": {
      "date_created": {
        "type": "date",
        "format": "yyyy-MM-dd HH:mm:ss"
      }
    }
  }
}

PUT test/_doc/1
{
  "date_created" : "2008-02-29 00:00:00"
}

```

The document got indexed successfully as it is not using a week based year, but the year-of-era.

Can you please provide a minimal **exact** reproduction under 7.4.1 including index creation and mapping, so we can figure out what is going on and what is different to my sample, that yours does not work?

Thank you!

---

<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: [November 28, 2019, 12:42pm UTC](https://discuss.elastic.co/t/type-date-time-exception-reason-invalid-date-february-29-as-1970-is-not-a-leap-year/205570/7 "2019-11-28T12:42:34Z")

</div>

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