AW: Query help!!

AW: Query help!!

 

  

Hi,

in hours, this is trivial

select sysdate - to_date('21/01/2004','DD/MM/YYYY') from dual

as you can calculate arithmtic expression with date values. To separate
days, hours and the like try that one which is based on the well known
properties of the trusty modulo function.

/* SQL starts */

-- where do all the little users from
select username,
to_char( created, 'dd-mon-yyyy hh24:mi:ss' ) "user creation",
to_char( sysdate, 'dd-mon-yyyy hh24:mi:ss' ) "now",
trunc( sysdate-created ) "Days between",
trunc( mod( (sysdate-created)*24, 24 ) ) "Hours",
trunc( mod( (sysdate-created)*24*60, 60 ) ) "Minutes",
trunc( mod( (sysdate-created)*24*60*60, 60 ) ) "Seconds",
to_char(trunc( sysdate-created )) || ' Days, ' ||
to_char(trunc( mod( (sysdate-created)*24, 24 ))) || ' hours, ' ||
to_char(trunc( mod( (sysdate-created)*24*60, 60 ))) || ' minutes and
' ||
to_char(trunc( mod( (sysdate-created)*24*60*60, 60 ))) || ' seconds
elapsed since user creation' "elapsed",
sysdate-created "days since user creation",
(sysdate-created)*24 "hours since user creation",
(sysdate-created)*24*60 "minutes since user creation",
(sysdate-created)*24*60*60 "seconds since user creation"
from all_users
where rownum < 5

/* SQL ends */

hope this helps,

gd

-----Ursprüngliche Nachricht-----
Von: Patel Daxa
[mailto:oracledba-ezmlmshield-x89460609.[Email address protected]
Gesendet: Monday, January 31, 2005 6:52 PM
An: LazyDBA Discussion
Betreff: RE: Query help!!



Hi all
Does anybody have a function or SQL script to receive the
difference between 2 dates in hours and minutes?
Thanks in advance
Daxa



--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: see http://www.lazydba.com
By using this list you agree to these
terms:http://www.lazydba.com/legal.html

Oracle LazyDBA home page