Subject | Re: Calculating time |
---|---|
Author | Svein Erling Tysvær |
Post date | 2004-09-22T12:18:13Z |
Hi Primoz.
The type 'time' is not a duration, but the exact point in time (e.g.
3:15 am). It makes sense to ask questions like "I came in 1am and left
3am. How long time did I spend there?" It doesn't make any sense to
say "I came at 1am and left at 3am. How long time did I spend there if
I also subtract 0:30am from the result?". Subtracting a point in time
from a duration is as sensible as subtracting weight from litres -
it's incompatible and cannot be done.
If your fields contain duration, then don't use time fields at all.
Or, if the first two really are a point in time, then keep the third
as an integer value:
<Time1>-<Time2>-<number of seconds>, or in your case:
3:00:00 - 1:00:00 - 1800
HTCUC (Hope This Clears Up Confusion),
Set
The type 'time' is not a duration, but the exact point in time (e.g.
3:15 am). It makes sense to ask questions like "I came in 1am and left
3am. How long time did I spend there?" It doesn't make any sense to
say "I came at 1am and left at 3am. How long time did I spend there if
I also subtract 0:30am from the result?". Subtracting a point in time
from a duration is as sensible as subtracting weight from litres -
it's incompatible and cannot be done.
If your fields contain duration, then don't use time fields at all.
Or, if the first two really are a point in time, then keep the third
as an integer value:
<Time1>-<Time2>-<number of seconds>, or in your case:
3:00:00 - 1:00:00 - 1800
HTCUC (Hope This Clears Up Confusion),
Set
--- In firebird-support@yahoogroups.com, "Planles" wrote:
> Hi!
>
> Subtracting two times fields we get seconds in decimal format.
> This doesn't bother me anymore, if I want to subtract two time
> fields.
>
> How can I substract 3 fields: time1 - time2 - time3
>
> example:
> 3:00:00 - 1:00:00 - 0:30:00 = 1:30:00 (or 5400 sec)