# ValueError: time data did not match format:

**URL:** <https://forum.inductiveautomation.com/t/valueerror-time-data-did-not-match-format/9223>\
**Category:** Ignition\
**Created:** [October 24, 2014, 12:47pm UTC](https://forum.inductiveautomation.com/t/valueerror-time-data-did-not-match-format/9223 "2014-10-24T12:47:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stokstaart](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@stokstaart](https://forum.inductiveautomation.com/u/stokstaart)\
**Post date:** [October 24, 2014, 12:47pm UTC](https://forum.inductiveautomation.com/t/valueerror-time-data-did-not-match-format/9223/1 "2014-10-24T12:47:53Z")

</div>

We have a page where we perfomr a query through a button via script:

`if event.source.parent.getComponent('CheckBox').selected ==True:
	aadate=str(event.source.parent.getComponent('Popup Calendar').date)
	maxdate=datetime.datetime.strptime(aadate, '%a %b %d %H:%M:%S %Z %Y')
#If checkbox not enabled use current time
else:
	maxdate=time.strftime('%Y-%m-%d %H:%M:%S')`

Now when i perform this query as the first thing when i startup the developer i get the following error:

```auto
ValueError: time data did not match format: data=Fri Sep 26 00:48:45 CEST 2014 fmt=%a %b %d %H:%M:%S %Z %Y
```

(is it me or does the str match the format?)

This happens on the line:

```auto
maxdate=datetime.datetime.strptime(aadate, '%a %b %d %H:%M:%S %Z %Y')
```

However:  
a)when i execute another (similar-)query and after that come back to the query above it performs as expected…

b) i just started up the designer and performed the query, as expected i got the error message, then just waited a while (didn’t alter a thing) and performed the query again, second time no error it performed as expected…

Is this a bug? Does performing another (select-) query alter some sort of magical data i can not comprehend?  
Could anyone help me with this issue??

---

<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:** [October 27, 2014, 10:14am UTC](https://forum.inductiveautomation.com/t/valueerror-time-data-did-not-match-format/9223/2 "2014-10-27T10:14:46Z")

</div>

Is the date a correctly formatted date for the locale?

---

<div class="post-metadata">

**Author:** ![stokstaart](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@stokstaart](https://forum.inductiveautomation.com/u/stokstaart)\
**Post date:** [October 28, 2014, 11:27am UTC](https://forum.inductiveautomation.com/t/valueerror-time-data-did-not-match-format/9223/3 "2014-10-28T11:27:59Z")

</div>

Not sure i understand your question here, could you elaborate a little bit?

---

<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:** [October 28, 2014, 1:17pm UTC](https://forum.inductiveautomation.com/t/valueerror-time-data-did-not-match-format/9223/4 "2014-10-28T13:17:10Z")

</div>

When I see this error:

```auto
ValueError: time data did not match format: data=Fri Sep 26 00:48:45 CEST 2014 fmt=%a %b %d %H:%M:%S %Z %Y
```

and everything looks okay, it usually has something to do with locale (EN-us, ES-sp, SL-sl, etc.) and the format of the date, especially days of the week and names of months. I was just verifying that the date given matched the locale you are using.

[An example of locale issue here](https://www.inductiveautomation.com/forum/viewtopic.php?p=43508).
