# Convert DateTime to Unix value

**URL:** <https://forum.inductiveautomation.com/t/convert-datetime-to-unix-value/94255>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 6, 2024, 7:53pm UTC](https://forum.inductiveautomation.com/t/convert-datetime-to-unix-value/94255 "2024-08-06T19:53:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neil\_Carty](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Neil\_Carty](https://forum.inductiveautomation.com/u/Neil_Carty)\
**Post date:** [August 6, 2024, 7:53pm UTC](https://forum.inductiveautomation.com/t/convert-datetime-to-unix-value/94255/1 "2024-08-06T19:53:24Z")

</div>

Hi all. I am using the value[0] of the XTrace on a power chart to query a historical tags value to display the value that was active at the time. i have my named query all set up but i need to convert the DateTime data type of the XTrace value to Unix time to query the Ignition historian. I have the Xtrace value tied to a memory tag and i am trying to use a Value Changed script to covert this. Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Neil\_Carty](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@Neil\_Carty](https://forum.inductiveautomation.com/u/Neil_Carty)\
**Post date:** [August 6, 2024, 9:08pm UTC](https://forum.inductiveautomation.com/t/convert-datetime-to-unix-value/94255/2 "2024-08-06T21:08:21Z")

</div>

Figured this out, used toMillis in a function tag and it produced the value that i was looking for.
