# Unparseable date

**URL:** <https://forum.inductiveautomation.com/t/unparseable-date/64131>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [September 15, 2022, 6:54pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131 "2022-09-15T18:54:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![israel.jordan](https://avatars.discourse-cdn.com/v4/letter/i/ce73a5/32.png) [@israel.jordan](https://forum.inductiveautomation.com/u/israel.jordan)\
**Post date:** [September 15, 2022, 6:54pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/1 "2022-09-15T18:54:54Z")

</div>

Hello,

I have been trying to export a dataset to CSV. The export is working but I am also trying to format the date/time. Currently it is being exported in the form “Tue Sep 13 02:16:56 PDT 2022” but I need to be in this form “2022-09-13 02:16:56.107”. I have tried using

```auto
system.date.parse(myDataset.getValueAt(row,column), "yyyy-MM-dd HH:mm:ss.SSS")

```

As well as

```auto
system.dataset.formatDates(myDataset, "yyyy-MM-dd HH:mm:ss.SSS")

```

But I haven’t been able to get either to work for me. When I use **system.date.parse** , I get

```auto
java.text.ParseException: java.text.ParseException: Unparseable date: "Tue Sep 13 02:16:56 PDT 2022"

```

And when I use **system.dataset.formatDates** , the execution seems to skip over the line of code because the dates have not changed in the export.

Can someone please let me know what I am doing wrong?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 15, 2022, 7:05pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/2 "2022-09-15T19:05:42Z")

</div>

Can you start by printing the type of the value in the dataset?

```auto
print type(myDataset.getValueAt(row,column))

```

Whether it is a text representation of a date or a Date object will determine what the next steps in the transformation are.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 15, 2022, 7:43pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/3 "2022-09-15T19:43:15Z")

</div>

Sounds like you aren’t assigning the return value from [system.dataset.formatDates](https://docs.inductiveautomation.com/display/DOC81/system.dataset.formatDates). Datasets are immutable–unchangeable. Functions like this one return a new dataset with the requested changes. Assign that to your table. (Or feed it to your CSV conversion.)

---

<div class="post-metadata">

**Author:** ![israel.jordan](https://avatars.discourse-cdn.com/v4/letter/i/ce73a5/32.png) [@israel.jordan](https://forum.inductiveautomation.com/u/israel.jordan)\
**Post date:** [September 15, 2022, 8:14pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/4 "2022-09-15T20:14:23Z")

</div>

I have printed the type and it is ‘unicode’.

---

<div class="post-metadata">

**Author:** ![israel.jordan](https://avatars.discourse-cdn.com/v4/letter/i/ce73a5/32.png) [@israel.jordan](https://forum.inductiveautomation.com/u/israel.jordan)\
**Post date:** [September 15, 2022, 8:25pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/5 "2022-09-15T20:25:43Z")

</div>

I am using [system.dataset.formatDates](https://docs.inductiveautomation.com/display/DOC81/system.dataset.formatDates) like this:

```auto
myNewDataset = system.dataset.formatDates(myDataset, "yyyy-MM-dd HH:mm:ss.SSS")
filePathPD = system.dataset.exportCSV("processedData.csv", 1, myNewDataset)

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 15, 2022, 8:34pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/6 "2022-09-15T20:34:20Z")

</div>

`formatDates` only works when the column type is actually Date, and yours appear to be String (unicode).

If you can’t get the Dataset to have a Date column in the first place, you’ll have to do this in 2 steps:

1. parse the String representation you find in that column into an actual Date
2. format that Date object back into the desired String format

---

<div class="post-metadata">

**Author:** ![israel.jordan](https://avatars.discourse-cdn.com/v4/letter/i/ce73a5/32.png) [@israel.jordan](https://forum.inductiveautomation.com/u/israel.jordan)\
**Post date:** [September 15, 2022, 8:45pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/7 "2022-09-15T20:45:10Z")

</div>

I have tried using `system.date.parse(myDataset.getValueAt(row,column), 'MMMM dd, yyyy hh:mm')` to create a Date object but I still get the error:  
`java.text.ParseException: java.text.ParseException: Unparseable date: "Tue Sep 13 02:16:56 PDT 2022"` How can I get past this?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 15, 2022, 8:46pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/8 "2022-09-15T20:46:30Z")

</div>

Probably by providing the right format to `parse` - you need to match the format the date is currently in.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 15, 2022, 8:51pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/9 "2022-09-15T20:51:40Z")

</div>

> [@israel.jordan](#):
>
> Tue Sep 13 02:16:56 PDT 2022

This worked for me, [here](https://docs.inductiveautomation.com/display/DOC81/Data+Type+Formatting+Reference) is a link to the date formatting reference

```auto
dateStr = "Tue Sep 13 02:16:56 PDT 2022"
print system.date.parse(dateStr, "E MMM dd HH:mm:ss Z yyyy")

```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [September 16, 2022, 9:33am UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/10 "2022-09-16T09:33:09Z")

</div>

> [@dkhayes117](#):
>
> `E MMM dd HH:mm:ss Z yyyy`

This format seems to be the default, meaning you probably are making the dataset wrong somewhere earlier.

How is the dataset being filled?

---

<div class="post-metadata">

**Author:** ![israel.jordan](https://avatars.discourse-cdn.com/v4/letter/i/ce73a5/32.png) [@israel.jordan](https://forum.inductiveautomation.com/u/israel.jordan)\
**Post date:** [September 16, 2022, 3:30pm UTC](https://forum.inductiveautomation.com/t/unparseable-date/64131/11 "2022-09-16T15:30:27Z")

</div>

Parsing the String representation and getting an actual Date was enough to make `system.dataset.formatDates` work
