<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Oracle date / time calcuation ! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992019#M924030</link>
    <description>hi,&lt;BR /&gt;&lt;BR /&gt;we use quite a different approach to timing procedure execution. We calculate the processing time in the procedure itself and store it as numbers.&lt;BR /&gt;&lt;BR /&gt;Example.&lt;BR /&gt;yd@MYDB.MU&amp;gt; DECLARE&lt;BR /&gt;  2   v_hsec   PLS_INTEGER := DBMS_UTILITY.get_time;&lt;BR /&gt;  3  BEGIN&lt;BR /&gt;  4  dbms_lock.sleep( 2 );&lt;BR /&gt;  5  DBMS_OUTPUT.put_line ('Procedure 1 sec = ' || (DBMS_UTILITY.get_time - v_hsec) / 100);&lt;BR /&gt;  6* END;&lt;BR /&gt;Procedure 1 sec = 2.05&lt;BR /&gt;&lt;BR /&gt;PL/SQL procedure successfully completed.&lt;BR /&gt;&lt;BR /&gt;Elapsed: 00:00:04.09&lt;BR /&gt;yd@MYDB.MU&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hence, you can just calculate the value and store it in the table column at the end of the procedure execution.&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Yogeeraj</description>
    <pubDate>Mon, 09 Jun 2003 11:24:37 GMT</pubDate>
    <dc:creator>Yogeeraj_1</dc:creator>
    <dc:date>2003-06-09T11:24:37Z</dc:date>
    <item>
      <title>Oracle date / time calcuation !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992016#M924027</link>
      <description>Hi there,&lt;BR /&gt;&lt;BR /&gt;I am just thinking of creating a statistic table to keep track the start time, end time and duration of the batch run.  However, it seems I cannot calcuate and display the duration in correct format (HH:MM:SS or just in minutes)&lt;BR /&gt;&lt;BR /&gt;Table script:&lt;BR /&gt;create table stat&lt;BR /&gt;( batch_name  char(35),&lt;BR /&gt;  status      char(12),&lt;BR /&gt;  start_time  date,&lt;BR /&gt;  end_time    date,&lt;BR /&gt;  duration    date);&lt;BR /&gt;&lt;BR /&gt;When the batch start, a record will be inserted to the table:&lt;BR /&gt;&lt;BR /&gt;insert into stat (batch_name, status, start_time) values ('batch a', 'progressing', sysdate);&lt;BR /&gt;&lt;BR /&gt;When the process end, I am trying to update the same record but I don't know how to display the duration correctly....&lt;BR /&gt;&lt;BR /&gt;update stat set stat='completed', end_time=sysdate, duration=end_time - start_time where process_name='batch a';&lt;BR /&gt;&lt;BR /&gt;Any idea ?  Appreciated for your inputs !!&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Chris,</description>
      <pubDate>Mon, 09 Jun 2003 08:46:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992016#M924027</guid>
      <dc:creator>Chris Fung</dc:creator>
      <dc:date>2003-06-09T08:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle date / time calcuation !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992017#M924028</link>
      <description>Oracle returns the difference in   integer number of days and decimal portion of day. This  value must be converted manually to be displayed in the  format desired. &lt;BR /&gt;You must use PL/SQL or other program code to display date   differences in the format Years, Months, Days, Hours,   Minutes, Seconds.  &lt;BR /&gt;The following example loads a table with 2 records with 2 date values for starting and ending dates. The pl/sql    block will calculate the difference of the dates and display   the result in the format described above.           create table ddiff   (stdate date,    endate date);       insert into ddiff (stdate,endate) values   (to_date('01-jan-96 00:00:00','dd-mon-yy hh24:mi:ss'),    to_date('01-mar-97 01:01:01','dd-mon-yy hh24:mi:ss'));      insert into ddiff (stdate,endate) values   (to_date('01-jun-99 00:00:00','dd-mon-yy hh24:mi:ss'),    to_date('03-oct-99 02:02:02','dd-mon-yy hh24:mi:ss'));     set echo off   set serverout on   declare     cursor c1 is        select stdate,endate from ddiff;     date_res number;     end_now date;     f_end_now char(20);     st_now date;     temp_now date;     f_st_now char(20);     yy_now number := 0;     mm_now number := 0;     dd_now number := 0;     hh_now number := 0;     f_hh_now number := 0;     mi_now number := 0;     f_mi_now number := 0;     ss_now number := 0;     f_ss_now number := 0;   begin     open c1;     loop       fetch c1 into st_now, end_now;       exit when c1%notfound;         -- Make st_now the earlier date       if (end_now &amp;lt; st_now) then         temp_now := end_now;         end_now := st_now;         st_now := temp_now;       end if;       f_end_now := to_char(end_now,'Mon-dd-yyyy hh24:mi:ss');       f_st_now  := to_char(st_now,'Mon-dd-yyyy hh24:mi:ss');         yy_now := trunc(months_between(end_now,st_now)/12);       mm_now := mod(trunc(months_between(end_now,st_now)),12);       dd_now :=    trunc(end_now-add_months(st_now,months_between(end_now,st_now)));     date_res := (end_now-st_now);         hh_now := (date_res-floor(date_res))*24;   f_hh_now := trunc(hh_now);       mi_now := (hh_now-floor(hh_now))*60;       f_mi_now := trunc(mi_now);       ss_now := (mi_now-floor(mi_now))*60;       f_ss_now := round(ss_now);         dbms_output.put_line(chr(10)||          'The time difference between ');       dbms_output.put_line('starting date '||f_st_now);       dbms_output.put_line('and ending date '||          f_end_now||' is');       dbms_output.put_line(chr(10)||yy_now||' year(s), '||         mm_now||' month(s), '||dd_now||' day(s)');       dbms_output.put_line('and '||f_hh_now||' hour(s), '||          f_mi_now||' minute(s), '||          f_ss_now||' second(s)');     end loop;     close c1;   end;   /</description>
      <pubDate>Mon, 09 Jun 2003 09:08:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992017#M924028</guid>
      <dc:creator>twang</dc:creator>
      <dc:date>2003-06-09T09:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle date / time calcuation !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992018#M924029</link>
      <description>repost the sample script.</description>
      <pubDate>Mon, 09 Jun 2003 09:10:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992018#M924029</guid>
      <dc:creator>twang</dc:creator>
      <dc:date>2003-06-09T09:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Oracle date / time calcuation !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992019#M924030</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;we use quite a different approach to timing procedure execution. We calculate the processing time in the procedure itself and store it as numbers.&lt;BR /&gt;&lt;BR /&gt;Example.&lt;BR /&gt;yd@MYDB.MU&amp;gt; DECLARE&lt;BR /&gt;  2   v_hsec   PLS_INTEGER := DBMS_UTILITY.get_time;&lt;BR /&gt;  3  BEGIN&lt;BR /&gt;  4  dbms_lock.sleep( 2 );&lt;BR /&gt;  5  DBMS_OUTPUT.put_line ('Procedure 1 sec = ' || (DBMS_UTILITY.get_time - v_hsec) / 100);&lt;BR /&gt;  6* END;&lt;BR /&gt;Procedure 1 sec = 2.05&lt;BR /&gt;&lt;BR /&gt;PL/SQL procedure successfully completed.&lt;BR /&gt;&lt;BR /&gt;Elapsed: 00:00:04.09&lt;BR /&gt;yd@MYDB.MU&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hence, you can just calculate the value and store it in the table column at the end of the procedure execution.&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Yogeeraj</description>
      <pubDate>Mon, 09 Jun 2003 11:24:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/oracle-date-time-calcuation/m-p/2992019#M924030</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2003-06-09T11:24:37Z</dc:date>
    </item>
  </channel>
</rss>

