# Convert a string value tag into dateTime

**URL:** <https://forum.inductiveautomation.com/t/convert-a-string-value-tag-into-datetime/54713>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 6, 2022, 10:02am UTC](https://forum.inductiveautomation.com/t/convert-a-string-value-tag-into-datetime/54713 "2022-01-06T10:02:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vani161998](https://avatars.discourse-cdn.com/v4/letter/v/ee7513/32.png) [@vani161998](https://forum.inductiveautomation.com/u/vani161998)\
**Post date:** [January 6, 2022, 10:02am UTC](https://forum.inductiveautomation.com/t/convert-a-string-value-tag-into-datetime/54713/1 "2022-01-06T10:02:30Z")

</div>

I have a string value ‘20211228064508000’ in a tag . i want to convert into current date format. I tried to change the data type of tag to Datetime but it didn’t work. Anybody have any solution?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [January 6, 2022, 10:05am UTC](https://forum.inductiveautomation.com/t/convert-a-string-value-tag-into-datetime/54713/2 "2022-01-06T10:05:49Z")

</div>

What does it represent ? Is it 2021 12 28 064508000 ?

Expressions might help you convert it to what you want:  
[https://docs.inductiveautomation.com/display/DOC81/Date+and+Time](https://docs.inductiveautomation.com/display/DOC81/Date+and+Time)

edit: Actually the proper question would be: Where does the data come from ? How do you get that string ?

---

<div class="post-metadata">

**Author:** ![vani161998](https://avatars.discourse-cdn.com/v4/letter/v/ee7513/32.png) [@vani161998](https://forum.inductiveautomation.com/u/vani161998)\
**Post date:** [January 6, 2022, 12:04pm UTC](https://forum.inductiveautomation.com/t/convert-a-string-value-tag-into-datetime/54713/3 "2022-01-06T12:04:45Z")

</div>

I get that string value from a XML file which is generated by a system . i need to convert this string into datetime format. I tried all the expression but it didn’t work.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [January 6, 2022, 12:41pm UTC](https://forum.inductiveautomation.com/t/convert-a-string-value-tag-into-datetime/54713/4 "2022-01-06T12:41:49Z")

</div>

> [@vani161998](#):
>
> 20211228064508000

Can you tell us more about its format ? Is it 2021 12 28 + time ?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 6, 2022, 1:01pm UTC](https://forum.inductiveautomation.com/t/convert-a-string-value-tag-into-datetime/54713/5 "2022-01-06T13:01:30Z")

</div>

`system.date.parse()` should do the trick depending on exactly how the string is to be interpreted.

For instance:

```python
date_string = '20211228064508000'
print system.date.parse(datestring,'yyyyMMddHHmmssSSS')

```

prints the following:

```auto
Tue Dec 28 06:45:08 EST 2021

```

Note that I’m in the eastern standard time zone and didn’t supply a locale to the function. If you need to convert timezones, you’ll need to provide a local.

Also, I made an assumption about what the substrings meant, if you provide what the expected result of the parsing should be we can provide a more accurate formatString.

That information can all be found at these places:  
[https://docs.inductiveautomation.com/display/DOC81/system.date.parse](https://docs.inductiveautomation.com/display/DOC81/system.date.parse)  
[https://docs.inductiveautomation.com/display/DOC81/Data+Type+Formatting+Reference](https://docs.inductiveautomation.com/display/DOC81/Data+Type+Formatting+Reference)
