Re: date/time arithmetic

From: Mike J Cox <mike_at_kane.demon.co.uk>
Date: 1995/06/25
Message-ID: <325696242wnr_at_kane.demon.co.uk>#1/1


>
> I can do this to get the number of minutes
>
> select (to_number(to_char(stop_time, 'hh24'))
> - to_number(to_char(start_time, 'hh24')))
> * 60
> + to_number(to_char(trunc(stop_time, 'mi'),'mi'))
> - to_number(to_char(trunc(start_time,'mi'),'mi'))
> from <table_name>;
>
> and then reformat the result myself to print as hours and minutes,
> but I'm hoping there is an easier way.
>
> TIA
>
>
>

Something along the lines of
select to_char(to_date('01-jan-00')+<in here put you calc>,'mi'),

       to_char(to_date('01-jan-00')+<in here put you calc>,'ss') from sys.dual

ditto ss for seconds etc etc

You may just be able to put a to_char( .... ,'mi') around you calculation, not sure give it a go.

Mike

-- 
******************************************************************************
Michael Cox          Input Technolgies Ltd
Email                mike_at_kane.demon.co.uk
Compuserve           100045.1715_at_compuserve.com
******************************************************************************
Received on Sun Jun 25 1995 - 00:00:00 CEST

Original text of this message