Page 1 of 1

Time conversion > 24 hours returns zero

Posted: 03.07.2008, 16:02
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

Posted: 04.07.2008, 09:25
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

Posted: 04.07.2008, 09:42
by Jona
Hi Ben,

casting the result to a CHAR value did the trick.

Many thanks,
Jona