Subject | Re: [ib-support] Subtract two TimeStamp-Fields |
---|---|
Author | guido.klapperich@t-online.de |
Post date | 2001-02-27T00:21:17Z |
Thanks, that works. Is it possible to cast the duration back to TIME. For example,
I have 5400 sec and I want display the value as 01:30.
Guido.
"Ann W. Harrison" wrote:
I have 5400 sec and I want display the value as 01:30.
Guido.
"Ann W. Harrison" wrote:
> At 02:51 PM 2/26/2001 +0100, guido.klapperich@... wrote:
> >I have two fields in a table
> >Start TimeStamp (for example 19.02.2001 8:00)
> >End TimeStamp (for example 20.02.2001 9:00)
> >and I want the duration between these two fields. I tried something like
> >
> >that
> >cast ((End-Start) as Numeric(9,3))
> >to get the seconds, that has gone by between these two points. But I get
> >
> >an conversion error. Can anybody help me.
>
> Subtracting a time from a time gives a number of seconds. Subtracting
> a timestamp from a timestamp gives a number of days.
>
> This worked for me:
>
> SQL> create table foo (foots timestamp, foot time, food date, fooi double
> precision);
> SQL> commit;
> SQL> insert into foo values ('now', '11:11:11.123', 'today', NULL);
> SQL> select * from foo;
>
> FOOTS FOOT FOOD FOOI
> ========================= ============= =========== =======================
>
> 2001-02-26 10:07:55.0000 11:11:11.1230 2001-02-26 <null>
>
> SQL> select cast ('now' as timestamp) - foots from foo;
>
> 0.000590277
>
> SQL> select cast ('12:00:00.000' as time ) - foot from foo;
>
> 2928.8770
>
> SQL> select cast (cast ('now' as timestamp) - foots as numeric (9,3)) from foo;
>
> 0.003
>
> Regards,
>
> Ann
> www.ibphoenix.com
> We have answers.
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/