Subject | RE: [firebird-support] Time calculation, with time response |
---|---|
Author | Svein Erling Tysvær |
Post date | 2008-11-10T07:20:25Z |
Hi Roberto!
As Helen said, TIME is a point in time, not a duration and should be stored in some kind of number rather than date. Rules are:
TIME - TIME = NUMBER
TIME - NUMBER = TIME
It is possible to fool Firebird by making it believe that time is a number, e.g.
Select
time '15:00:0.000' - (time '14:04:42.000' - time '0:00:00.000')
from rdb$database;
but then you're using TIME in a way it wasn't intended, so be a bit careful (e.g. I work 37.5 hours every week, and that is a number that cannot be stored in a TIME field).
Set
-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Roberto Carlos
Sent: 10. november 2008 02:59
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Time calculation, with time response
How can I calculate this?
Select
time '15:00:0.000' - time '14:04:42.000',
cast('15:00:0.000' as time) - Cast('14:04:42.000' as time),
cast(3318.0000 as time),
cast(cast('15:00:0.000' as time) - Cast('14:04:42.000' as time) as time)
From rdb$Database;
The first two even work, but I can not transfom them into time fields.
As Helen said, TIME is a point in time, not a duration and should be stored in some kind of number rather than date. Rules are:
TIME - TIME = NUMBER
TIME - NUMBER = TIME
It is possible to fool Firebird by making it believe that time is a number, e.g.
Select
time '15:00:0.000' - (time '14:04:42.000' - time '0:00:00.000')
from rdb$database;
but then you're using TIME in a way it wasn't intended, so be a bit careful (e.g. I work 37.5 hours every week, and that is a number that cannot be stored in a TIME field).
Set
-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Roberto Carlos
Sent: 10. november 2008 02:59
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Time calculation, with time response
How can I calculate this?
Select
time '15:00:0.000' - time '14:04:42.000',
cast('15:00:0.000' as time) - Cast('14:04:42.000' as time),
cast(3318.0000 as time),
cast(cast('15:00:0.000' as time) - Cast('14:04:42.000' as time) as time)
From rdb$Database;
The first two even work, but I can not transfom them into time fields.