# dateFormat expression issue

**URL:** <https://forum.inductiveautomation.com/t/dateformat-expression-issue/8872>\
**Category:** Ignition\
**Created:** [August 7, 2014, 3:18am UTC](https://forum.inductiveautomation.com/t/dateformat-expression-issue/8872 "2014-08-07T03:18:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gekkoman](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gekkoman](https://forum.inductiveautomation.com/u/gekkoman)\
**Post date:** [August 7, 2014, 3:18am UTC](https://forum.inductiveautomation.com/t/dateformat-expression-issue/8872/1 "2014-08-07T03:18:22Z")

</div>

Ign 7.7.0 (b2014071516) | 64-bit

I have an issue using dateFormat in a textbox.text field

Here is an example that you can reproduce

This works

dateFormat({[System]Client/System/CurrentDateTime},{[System]Client/System/CurrentDateTime.FormatString})

This does not

dateFormat(tag("[System]Client/System/CurrentDateTime"),{[System]Client/System/CurrentDateTime.FormatString})

Type mismatch, arg 0 error invalid type

But

tag("[System]Client/System/CurrentDateTime")

displays date text ok.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 7, 2014, 1:37pm UTC](https://forum.inductiveautomation.com/t/dateformat-expression-issue/8872/2 "2014-08-07T13:37:27Z")

</div>

It appears the tag() returns the date value as a string. dateFormat() requires it to be a date.

Try `dateFormat(toDate(tag("[System]Client/System/CurrentDateTime")),{[System]Client/System/CurrentDateTime.FormatString})
`

---

<div class="post-metadata">

**Author:** ![gekkoman](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@gekkoman](https://forum.inductiveautomation.com/u/gekkoman)\
**Post date:** [August 8, 2014, 6:07am UTC](https://forum.inductiveautomation.com/t/dateformat-expression-issue/8872/3 "2014-08-08T06:07:55Z")

</div>

I also had to do a toStr on the formatstring.

Does this mean the tag call is returning the object repr rather than object.value? One would not expect to have to cast a string object.

My real example uses MES production model tags and this finally appears to work.

if (isNull(tag({[Client]MES/Selections/selectedLineTagPath}+"/Actual Start Time")),"",  
dateFormat(toDate(tag({[Client]MES/Selections/selectedLineTagPath}+"/Actual Start Time")),  
toStr(tag({[Client]MES/Selections/selectedLineTagPath}+"/Actual Start Time.FormatString"))))
