ValueError: time data did not match format:

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:

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:

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??

Is the date a correctly formatted date for the locale?

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

When I see this error:

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.