473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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:
report["COMPANY X"][1][2]

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

Jul 18 '05 #1
1 3215
Sorisio, Chris wrote:
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>

import mx.DateTime as dt
d = dt.DateTimeFrom("1969-12-31 00:00:00.00")
d <DateTime object for '1969-12-31 00:00:00.00' at a0f2ca0> int(d) -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:
epoch = dt.DateTimeFrom("1970-01-01 00:00:00")
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.
if d < epoch: .... 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
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
1
by: John | last post by:
I have a drop down that is showing dates, I need to pass the selected date to my proc, so I pass it like this; ...
11
by: Axel Dahmen | last post by:
Hi, I'm working in a team developing an international website. When I set the page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't seem to be able to parse a TextBox's date...
3
by: Rich Robinson | last post by:
Hi, I have a web service method which takes a DateTime type as a parameter. The service is UK based, and the dates are passed in to the service in the UK format dd/MM/yyyy. On a recent...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
3
by: Tim | last post by:
Folks, I'm trying to format a print string so that it reports progress whilst processing a looping structure with a date time stamp appended to the end of the string. This started out life as a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.