Subject | Re: substract two TIME values |
---|---|
Author | Adam |
Post date | 2006-10-12T00:15:08Z |
--- In firebird-support@yahoogroups.com, "d_dude_2003"
<d_dude_2003@...> wrote:
The question of duration makes no sense when you are referring to two
TIME fields. TIME is simply a way of expressing Hours and Minutes (ok
and seconds etc). Without the additional information of a DATE that is
included in a TIMESTAMP field, it makes no sense to speak of duration.
What is the difference between
'08:00' and '14:00'? It could be 6 hours, it could be 30 hours, in
fact there is theoretically an infinite number of possibilities.
What about
'13:00' and '03:00'? Is that meant to be 14 hours, or 10 hours, or
maybe 38?
I think you see the point. Whilst Firebird will let you subtract one
time field from another (returning the result in seconds), it is quite
a strange concept (to me anyway), and is unable to represent durations
of over 24 hours at all.
With a TIMESTAMP field, you have two absolute points that you can
locate the absolute duration between with no ambiguity. Subtracting
two timestamps returns the result in days.
So for
Time1 - Time2 -> Divide the time by (60seconds * 60minutes = 3600)
Timestamp1 - Timestamp2 -> Multiply the time by 24 hrs.
Adam
<d_dude_2003@...> wrote:
>Do you mean TIME or TIMESTAMP?
> Hi there folks,
>
> How do i convert the TIME2 - TIME1 (TIME2 > TIME1)
> to number of hours?
The question of duration makes no sense when you are referring to two
TIME fields. TIME is simply a way of expressing Hours and Minutes (ok
and seconds etc). Without the additional information of a DATE that is
included in a TIMESTAMP field, it makes no sense to speak of duration.
What is the difference between
'08:00' and '14:00'? It could be 6 hours, it could be 30 hours, in
fact there is theoretically an infinite number of possibilities.
What about
'13:00' and '03:00'? Is that meant to be 14 hours, or 10 hours, or
maybe 38?
I think you see the point. Whilst Firebird will let you subtract one
time field from another (returning the result in seconds), it is quite
a strange concept (to me anyway), and is unable to represent durations
of over 24 hours at all.
With a TIMESTAMP field, you have two absolute points that you can
locate the absolute duration between with no ambiguity. Subtracting
two timestamps returns the result in days.
So for
Time1 - Time2 -> Divide the time by (60seconds * 60minutes = 3600)
Timestamp1 - Timestamp2 -> Multiply the time by 24 hrs.
Adam