Hi. I have ran into a weird thing I just can't find any solution for. I
have googled and searched but no luck.
The problem is that when I select TIME values from MySQL from python, I
get wrong results when the TIME values are negative.
From mysql program:
mysqlselect id,flex from Users where id=2;
+----+----------+
| id | flex |
+----+----------+
| 2 | 00:30:00 |
+----+----------+
From python script:
SELECT id,flex FROM Users WHERE id=2
Data back from MySQLdb:
((2L, datetime.timede lta(0, 1800)),)
This looks good and fine, but this :
From mysql program:
mysqlselect id,flex from Users where id=2;
+----+-----------+
| id | flex |
+----+-----------+
| 2 | -00:30:00 |
+----+-----------+
From python :
SELECT id,flex FROM Users WHERE id=2
Data back from MySQLdb:
((2L, datetime.timede lta(0, 1800)),)
Not good, python thinks this is a positive value. One more:
mysqlselect id,flex from Users where id=2;
+----+-----------+
| id | flex |
+----+-----------+
| 2 | -01:30:00 |
+----+-----------+
Python :
SELECT id,flex FROM Users WHERE id=2
Data back from MySQLdb:
((2L, datetime.timede lta(-1, 84600)),)
At least its negative but this looks to me as -00:30 rather than
-01:30..... (86400-84600 = 1800, = 30 minutes)
And now a negative that works!:
mysqlselect id,flex from Users where id=2;
+----+-----------+
| id | flex |
+----+-----------+
| 2 | -10:00:00 |
+----+-----------+
Python:
SELECT id,flex FROM Users WHERE id=2
Data back from MySQLdb:
((2L, datetime.timede lta(-1, 50400)),)
This looks alright to me...(86400-50400 = 36000, = 10 hours)
Any ideas ? Have I missed something obvious here or ? It seems to be
offset by an hour or something....
I run python2.4 on debian sarge, MySQL 5.0.18 and python-mysqldb version
1.2.1-c2-1
Any help greatly appreciated. Thanx.
/ZW 0 1922 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Terry Hancock |
last post by:
What do you do when a date or time is
incompletely specified? ISTM, that as it is, there is no
formal way to store this --- you have to guess, and there's
no way to indicate that the guess is different from solid
information. As a result, I have sometimes had to abandon
datetime, even though it seemed like the logical choice for...
|
by: Andy Jackman |
last post by:
Hi,
1) I was investigating the unix_timestamp routine in mysql (version
3.23.46-nt) and for some reason the unix epoch (1-1-1970) was returned
with a value of -3600. Then, as you can see, it suddenly corrected
itself. I can't replicate this error, but it caused me to shudder.
Attached is the output from the command line client.
2) The...
|
by: Jim S. |
last post by:
I'm having a horrible time simply inserting the date in a MySQL
database through a Visual Basic program. I have a table, called
"ORDERS"; "ID" is the primary key. I'm trying the insert the date,
into the MySQL database, which is a DATETIME datatype. I must keep it
DATETIME so it can be accessed via Microsoft Access.
Here are two versions of...
|
by: Thomas Bartkus |
last post by:
MySQL Version 4.0.20 on a Linux server.
How does one get the elapsed time between (2) DateTime values?
I need the answer to the nearest minute.
Is upgrading to Ver 5 with its more robust date/time functions the only
solution?
You can directly subtract 2 DateTime values and a long integer results.
What is that number?
|
by: Propel Exacto |
last post by:
Hey guys,
I am using MySQL 4.0.18 and I have a field named "order_datetime" in
which I store data in the format 20041001 23:00:00 (for example Oct 1,
2004 11pm)
When I do a select statement to find dates in a given range, the
result set never includes records that have the ending date. For
example, if my SQL statement is
| |
by: Kenneth P |
last post by:
Hi,
I'm trying to use MySql 4.1 db instead of MSSql2k and am having problems
with the DateTime in the db.
In mysqladmtools 1.0.19 I'm recommended to use 0000-00-00 00:00:00 as the
default value, but you can't save these settings. If you read the manual they
say the default value is thbe one above but that you can't use it, you have
to...
|
by: Mike the Canadian |
last post by:
Suppose I have a MySQL 5 table with a DateTime field in it. The table
has two records where the time is blank. Running:
SELECT CAST(DateTimeField AS TIME) FROM MyTable
shows two records with NULL as the resultset. Running:
SELECT * FROM MyTable
WHERE CAST(DateTimeField AS TIME)=NULL
|
by: iulian.ilea |
last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy
into it? I choose this method because I have an application that runs
on more than one server. So, if I used a datetime field (MSSQL Server)
it worked on my test machine. If I run the same application on another
machine with different regional settings is not working. I...
|
by: electronik |
last post by:
I dont really have a problem, but I want to make my code faster and prettier.
I have some tables with DATETIME in it.
They have the std format %Y-%m-%d %H:%i:%s
I need them to be in %d.%m.%Y %H:%i format.
I tried to fix it with the server variable "datetime_format".
After reading a lot in mysql doc I found out that:
...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |