473,231 Members | 1,674 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,231 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 3204
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.