# Datetime.timedelta object

**URL:** <https://forum.inductiveautomation.com/t/datetime-timedelta-object/5762>\
**Category:** Ignition\
**Created:** [January 29, 2013, 9:44pm UTC](https://forum.inductiveautomation.com/t/datetime-timedelta-object/5762 "2013-01-29T21:44:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![markdobtech](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@markdobtech](https://forum.inductiveautomation.com/u/markdobtech)\
**Post date:** [January 29, 2013, 9:44pm UTC](https://forum.inductiveautomation.com/t/datetime-timedelta-object/5762/1 "2013-01-29T21:44:37Z")

</div>

I need to do some duration calculations in script using datetime.timedelta. One of the datetime arguments is from a sqltag with a datatype of datetime. The call is failing as it appears the sqltag does not convert to a datetime object for the calculation. I am not clear what should be done to convert the sqltag for use with a timedelta calculation.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [January 29, 2013, 9:51pm UTC](https://forum.inductiveautomation.com/t/datetime-timedelta-object/5762/2 "2013-01-29T21:51:03Z")

</div>

You can probably set the data type of the tag to a string and convert back and forth.

---

<div class="post-metadata">

**Author:** ![markdobtech](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@markdobtech](https://forum.inductiveautomation.com/u/markdobtech)\
**Post date:** [January 30, 2013, 3:42pm UTC](https://forum.inductiveautomation.com/t/datetime-timedelta-object/5762/3 "2013-01-30T15:42:27Z")

</div>

Travis, thanks for pointing me in the right direction. It worked converting it to a datetime object using datetime.strptime.
