# Can not use datetime.strptime in windows

**URL:** <https://forum.inductiveautomation.com/t/can-not-use-datetime-strptime-in-windows/7873>\
**Category:** General Discussion\
**Created:** [January 20, 2014, 1:05pm UTC](https://forum.inductiveautomation.com/t/can-not-use-datetime-strptime-in-windows/7873 "2014-01-20T13:05:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![domi](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@domi](https://forum.inductiveautomation.com/u/domi)\
**Post date:** [January 20, 2014, 1:05pm UTC](https://forum.inductiveautomation.com/t/can-not-use-datetime-strptime-in-windows/7873/1 "2014-01-20T13:05:38Z")

</div>

Hi

I want to get the "  
A = Value" of a datetime SQLTag  
add X seconds

And compare the result to another datetime.datetime( now() )

I searched in forum, found reference to strptime. However it does not work in windows (apparently not implemented). How to convert and SQLTag standard datetime to “datetime” python format (so I can use timedelta function) ?

Thanks

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [January 26, 2014, 4:34am UTC](https://forum.inductiveautomation.com/t/can-not-use-datetime-strptime-in-windows/7873/2 "2014-01-26T04:34:18Z")

</div>

what have you tried?

---

<div class="post-metadata">

**Author:** ![Robert.Cavagnaro](https://avatars.discourse-cdn.com/v4/letter/r/eb9ed0/32.png) [@Robert.Cavagnaro](https://forum.inductiveautomation.com/u/Robert.Cavagnaro)\
**Post date:** [May 6, 2014, 8:17pm UTC](https://forum.inductiveautomation.com/t/can-not-use-datetime-strptime-in-windows/7873/3 "2014-05-06T20:17:29Z")

</div>

I have had no difficulty using datetime.strptime in windows; the hardest part is often finding the right format string to use.

```auto
from datetime import datetime

fmt = '%Y-%m-%d %H:%M:%S'
thenTime = system.tag.read("thenTime").value
nowTime = system.tag.read("nowTime").value
convertedThenTime = datetime.strptime(thenTime, fmt)
convertedNowTime = datetime.strptime(nowTime, fmt)

diffTime = (convertedNowTime-convertedThenTime).seconds
```
