Time conversion > 24 hours returns zero

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Jona
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 14.01.2008, 14:35

Time conversion > 24 hours returns zero

Post by Jona »

Hi All,

I've tested following query on the MySQL Query Browser:
SELECT SEC_TO_TIME(86500);
which returns 24:01:40 (as it should be).

Now if I set up a simple Delphi form with following components: ZConnection --> ZQuery --> Datasource --> DBGrid
and execute the same query it returns 00:00:00 in the DBGrid. (values lower then 86400 are calculated correctly).

Is it an overflow occuring in the Zeos component or can't the DBGrid cope with time values greater then 24 hours?

I'm using Delphi 7 and Zeos 6.6.2-RC

Thanks for your help,
Jona
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

Jona,

It looks like Delphi's TTimeField is being used to represent your result. TTimeFields are limited to the range 00:00:00 .. 23:59:59.999.... and it looks like when Zeos is passed a value outside this range it returns 00:00:00 (See AnsiSQLDateToDateTime in the ZSysUtils unit).

You could try using:

Code: Select all

SELECT CAST(SEC_TO_TIME(86500) AS CHAR);
which would return your result as a string.

I hope this helps.

Regards,

Ben
Jona
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 14.01.2008, 14:35

Post by Jona »

Hi Ben,

casting the result to a CHAR value did the trick.

Many thanks,
Jona
Post Reply