# Vegalite unable to parse dates in format DD/MM/YYYY

**URL:** <https://discuss.elastic.co/t/vegalite-unable-to-parse-dates-in-format-dd-mm-yyyy/268206>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [March 24, 2021, 12:38pm UTC](https://discuss.elastic.co/t/vegalite-unable-to-parse-dates-in-format-dd-mm-yyyy/268206 "2021-03-24T12:38:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![usman1](https://avatars.discourse-cdn.com/v4/letter/u/c67d28/32.png) [@usman1](https://discuss.elastic.co/u/usman1)\
**Post date:** [March 24, 2021, 12:38pm UTC](https://discuss.elastic.co/t/vegalite-unable-to-parse-dates-in-format-dd-mm-yyyy/268206/1 "2021-03-24T12:38:41Z")

</div>

My log files have the timestamp as 13/10/2020 13:03 and Vegalite visualizations are being broken every time date is more than 12, which means it is taking month as days and vice versa.

Following is the line of code I am using for conversion:

```auto
    transform: [
      {
        calculate: "toDate(datum._source.TIMESTAMP)", 
        as: "time"
      }
    ]

```

TIMESTAMP attribute in the source is as follows:

```auto
    "TIMESTAMP" : "15/06/2020 17:18"

```

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [March 24, 2021, 1:01pm UTC](https://discuss.elastic.co/t/vegalite-unable-to-parse-dates-in-format-dd-mm-yyyy/268206/2 "2021-03-24T13:01:50Z")

</div>

I don't think `toDate` function recognizes your format so you need to [parse](https://github.com/d3/d3-time-format/) it.

**Specification**

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "data": [
    {
      "name": "table",
      "values": [{"TIMESTAMP": "15/06/2020 17:18"}],
      "transform": [
        {
          "type": "formula",
          "expr": "timeParse(datum.TIMESTAMP, '%d/%m/%Y %H:%M')",
          "as": "time"
        }
      ]
    }
  ]
}

```

**Returns**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/0/8054150d26279c6c12db9b8f0d3e2e685ce0b2a5.png)

\*\* You may need to do another transform for Time Zone depending on your use case. Also I did this in Vega, just need to change it back to `calculate` vs `formula`.

---

<div class="post-metadata">

**Author:** ![usman1](https://avatars.discourse-cdn.com/v4/letter/u/c67d28/32.png) [@usman1](https://discuss.elastic.co/u/usman1)\
**Post date:** [March 24, 2021, 2:00pm UTC](https://discuss.elastic.co/t/vegalite-unable-to-parse-dates-in-format-dd-mm-yyyy/268206/3 "2021-03-24T14:00:43Z")

</div>

Thanks @aaron-nimocks for this, really helpful. Just one more query, how can I quickly debug this (the way you showed what it returns)?

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [March 24, 2021, 2:03pm UTC](https://discuss.elastic.co/t/vegalite-unable-to-parse-dates-in-format-dd-mm-yyyy/268206/4 "2021-03-24T14:03:20Z")

</div>

Use the [Vega Editor](https://vega.github.io/editor/#/url/vega/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykSArJQBWENgDsQAGhAATJJhSoA2qHFIEcNCEVMANlpnEkehnAhpVIACoBJALIBRAMrWAgvYAK2gIwCCAAwAbAQATAHhAAQ+AOyoPgAcIAC+ALoymABOSOIQAGZsmQiWoJgAnjha6AVFDHooMnAAHjiZ2pg0mp5ImRBwABTymAwIlHZOrh6eUpEA5ACksgTzCMsAmpHzABKo8-azAJTSIEgW6B2aKalpyUA) and on the bottom right click Data Viewer and select the data source by the name you set in the spec.

If you are using a newer version of Kibana you can also [do it](https://www.elastic.co/guide/en/kibana/master/vega.html) on there.

---

<div class="post-metadata">

**Author:** ![usman1](https://avatars.discourse-cdn.com/v4/letter/u/c67d28/32.png) [@usman1](https://discuss.elastic.co/u/usman1)\
**Post date:** [March 24, 2021, 2:25pm UTC](https://discuss.elastic.co/t/vegalite-unable-to-parse-dates-in-format-dd-mm-yyyy/268206/5 "2021-03-24T14:25:40Z")

</div>

Thanks so much @aaron-nimocks. Apart from solving the issue, this thread has been helpful in knowing about the Debug feature which I know will be extremely useful in future.

---

<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:** [April 21, 2021, 2:26pm UTC](https://discuss.elastic.co/t/vegalite-unable-to-parse-dates-in-format-dd-mm-yyyy/268206/6 "2021-04-21T14:26:35Z")

</div>

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