Time sum bug

Time sum bug

am 01.11.2002 18:40:44 von Airton

From: airton@unitau.br
To: mysql-win32@lists.mysql.com
Subject: Time sum bug

Description:
When time type fields are summed and the result is less than 1 hour - ok.
If the result is more than 1 hour the result is zero - e.g.: 00:50:00 +
00:10:00 = 00:00:00.
If one time is more than 1 hour, ok too - e.g.: 01:00:00 + 00:45:00 =
01:45:00.


How-To-Repeat:
--> see above

Fix:


Synopsis:
Submitter-Id:
Originator: Airton Carrara
Organization: Universidade de Taubate
MySQL support: [none | licence | email support | extended email support ]
Severity: [non-critical | serious | critical ]
Priority: [low | medium | high ]
Category: [mysqld, mysql client, C, PHP, PERL, ...]
Class: sw-bug
Release: mysql 3.23.53-max-nt

Exectutable: mysqld-nt
Environment: Compaq - P4 1.6MHz - 256MB RAM
System: Win XP
Compiler: VC++ 6.0
Architecture: i


How-To-Repeat:

1.

# MySQL-Front Dump 2.5
#
# Host: localhost Database: timebug
# --------------------------------------------------------
# Server version 3.23.53-max-nt

#
# Table structure for table 'time'
#

DROP TABLE IF EXISTS time;
CREATE TABLE time (
id tinyint(3) unsigned NOT NULL auto_increment,
time1 time default NULL,
time2 time default NULL,
timesum time default NULL,
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY id_2 (id)
) TYPE=MyISAM;

#
# Dumping data for table 'time'
#

INSERT INTO time VALUES("1", "00:50:00", "00:10:00", "00:00:00");
INSERT INTO time VALUES("2", "00:50:00", "00:09:00", "00:59:00");
INSERT INTO time VALUES("3", "01:50:00", "00:09:00", "01:59:00");
INSERT INTO time VALUES("4", "10:50:00", "00:10:00", "00:00:00");



2.
update time set timesum = time1+time2





------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread12889@lists.mysql.com
To unsubscribe, e-mail

Re: Time sum bug

am 01.11.2002 18:54:22 von Sinisa Milivojevic

Airton writes:
> From: airton@unitau.br
> To: mysql-win32@lists.mysql.com
> Subject: Time sum bug
>
> Description:
> When time type fields are summed and the result is less than 1 hour - ok.
> If the result is more than 1 hour the result is zero - e.g.: 00:50:00 +
> 00:10:00 = 00:00:00.
> If one time is more than 1 hour, ok too - e.g.: 01:00:00 + 00:45:00 =
> 01:45:00.
>
>
> How-To-Repeat:
> --> see above


Hi!

TIME type is not designed so that such arithmetic can be applied
directly.

Instead, you have to use some functions, like this:

select sec_to_time(time_to_sec(time1) + time_to_sec(time2));

--
Regards,
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
<___/ www.mysql.com


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread12890@lists.mysql.com
To unsubscribe, e-mail