mx.DateTime.Error: cannot convert value to a time value

S

Sorisio, Chris

Ladies and gentlemen,

I've imported some data from a MySQL database into a Python dictionary. I'm
attempting to tidy up the date fields, but I'm receiving a
'mx.DateTime.Error: cannot convert value to a time value' error. It's
related to glibc returning an error to a pre-1970 date, I think.

My question: /how/ do I go through the Python direction I've created to
remove the pre-1970 date objects? Ideally, I would be able to iterate
through the dict and remove any DateTime objects that cause int() to fail.
Unfortunately, the DateTime error causes my script to abort entirely.

Ex:
<DateTime object for '1969-12-31 00:00:00.00' at a1e1548>
 
S

Steve Holden

Ladies and gentlemen,

I've imported some data from a MySQL database into a Python dictionary.
I'm attempting to tidy up the date fields, but I'm receiving a
'mx.DateTime.Error: cannot convert value to a time value' error. It's
related to glibc returning an error to a pre-1970 date, I think.
You don't say why you think this, though, which might help - when you
say you are "attempting to tidy up" the date fields, do you mean convert
them into time.time format, or what?
My question: /how/ do I go through the Python direction I've created to
remove the pre-1970 date objects? Ideally, I would be able to iterate
through the dict and remove any DateTime objects that cause int() to
fail. Unfortunately, the DateTime error causes my script to abort entirely.
Ah, I see. Well, this gives us a bit more of a clue: it's the int() of
an mx.DateTime object that throws up this error? [pauses to install
mx.DateTime ...]
Ex:
report["COMPANY X"][1][2]
<DateTime object for '1969-12-31 00:00:00.00' at a1e1548>
-68400

Hmm, are we using different versions of Python? (This was on Cygwin
2.3.3 with mx.DateTime from mxBase-2.0.5).


Anyway, now I seem to be more or less in the same position as you.
Clearly your system has mx.DateTime loaded (at least indirectly)
otherwise your dtabase couldn't have created those ms.DateTime objects.
It's not much of a problem to install if you don't have it loaded.

So, during initialization, have your program set the epoch:
<DateTime object for '1970-01-01 00:00:00.00' at a07ef60>

And then just compare the DateTimes to the epoch to decide whether they
can be used or not.
.... print "Throw this one away"
....
Throw this one away
Perhaps you aren;t getting that error for the reason you suppose,
however, in which case a little more information would be helpful.

regards
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top