Subject | Re: time data type and elapsed |
---|---|
Author | steve_carter_ben |
Post date | 2003-08-29T00:30:19Z |
Lucas,
So, for example, I can get the elapsed hours with something like
this sample SQL:
select
timeofpickup, timeofdropoff,
( (timeofdropoff - timeofpickup) + 86400) / 3600
from reserve
where timeofdropoff < timeofpickup
It's funny how simple the answer is once you know the answer!
As for the "crystal bowl" function (<grin>) -- this is a limousine
reservation app. I guess if the customer was going to keep the car
more than 24 hours, they'd pay a flat rate. So far, we haven't had
customers that extravagant.
Steve
Steve
--- In firebird-support@yahoogroups.com, Lucas Franzen <luc@r...>
wrote:
> If you are sure that the difference between these fields is lesstahn
> one day (otherwise you have to use the crystal bowl function) howabout
> adding the value for one day if your result is less than zero?Thanks. Of course -- why didn't I think of that?
So, for example, I can get the elapsed hours with something like
this sample SQL:
select
timeofpickup, timeofdropoff,
( (timeofdropoff - timeofpickup) + 86400) / 3600
from reserve
where timeofdropoff < timeofpickup
It's funny how simple the answer is once you know the answer!
As for the "crystal bowl" function (<grin>) -- this is a limousine
reservation app. I guess if the customer was going to keep the car
more than 24 hours, they'd pay a flat rate. So far, we haven't had
customers that extravagant.
Steve
Steve
--- In firebird-support@yahoogroups.com, Lucas Franzen <luc@r...>
wrote:
>clear.
>
> steve_carter_ben schrieb:
>
> > Helen,
> > Thanks for your responce, but I can see I did not make myself
> > It is not the fields of type date that are giving me trouble,but
> > the fields of type time.and a
> > For example, I have a field 'timeofpickup' with value '530 PM'
> > field 'timeofdropoff' with a value of 1:30 AM.representing
> > (I realize that internally these are stored as integers
> > milliseconds since midnight).it's a
> >
> > I can, of course do the following:
> > select
> > timeofpickup, timeofdropoff,
> > (timeofdropoff - timeofpickup)...
> >
> > but that gives me the unuseful value of -57600
> > <grin>.
>
> Which is perfectly ok since a time field doesn't store the day -
> time field not a datetime field.tahn
> If you are sure that the difference between these fields is less
> one day (otherwise you have to use the crystal bowl function) howabout
> adding the value for one day if your result is less than zero?exactly 8
>
> One day = 24 hours * 60 minutes * 60 seconds = 86400 seconds.
>
> if you add 86400 to -57600 you'll get 28860 seconds which is
> hours...zero.
>
> You can use (for example) stored proc to check for results below
>
> Luc.