title: What is the best way to find the current query time of active queries for a specific user/machine in Oracle SQL Developer for all running queries?
body: <p>I know how to find out what queries I have running by OSUSER but I am having trouble getting the logic to work out for developing a elapsed time field and could use some help. Here is what I have been looking at:</p>
  
  <p>CREATE OR REPLACE </p>
  
  <pre><code>MONITOR_ACTIVE_QUERIES VIEW AS 
  SELECT 
    USERNAME
  , SCHEMANAME
  , OSUSER
  , MACHINE
  , PROGRAM
  , SID
  , SERIAL#
  , TO_CHAR(SYSDATE, 'MM-DD-YYYY HH24:MI:SS') AS CurrentTime
  , FIRST_LOAD_TIME AS LoadTime
  --, USER_IO_WAIT_TIME &lt;&lt; not really sure what this is.
  , SQL_TEXT
  
  FROM V$SESSION a JOIN V$SQL b
  ON a.SQL_ADDRESS = b.ADDRESS
  WHERE a.OSUSER IN ('&lt;USER1&gt;', '&lt;USER2&gt;','&lt;USER3&gt;')
  AND a.STATUS = 'ACTIVE'
  </code></pre>
  
  <p>I want to do something where I can take the logic of CurrentTime - LoadTime to calculate a RunTime but keep running into issues. It appears to be data type driven. </p>
  
  <p>I did try this for the CurrentTime:
  TO_DATE((</p>
  
  <pre><code>SELECT MM || '-' || DD || '-' || YYYY || ' ' || HH24 || ':' || MI || ':' || SS 
     FROM (
      SELECT
        EXTRACT(MONTH FROM SYSTIMESTAMP) AS MM
      , EXTRACT(DAY FROM SYSTIMESTAMP) AS DD
      , EXTRACT(YEAR FROM SYSTIMESTAMP) AS YYYY
      , EXTRACT(HOUR FROM SYSTIMESTAMP) AS HH24
      , EXTRACT(MINUTE FROM SYSTIMESTAMP) AS MI
      , ROUND(EXTRACT(SECOND FROM SYSTIMESTAMP),0) AS SS
      FROM DUAL)),'MM-DD-YYYY HH24:MI:SS') AS CurrentTime
  </code></pre>
  
  <p>And this for the LoadTime:</p>
  
  <pre><code>SUBSTR(FIRST_LOAD_TIME,6,5) || '-' || SUBSTR(FIRST_LOAD_TIME,0,4) || ' ' || SUBSTR(FIRST_LOAD_TIME,12,8) AS LoadTime
  </code></pre>
  
  <p>I have even tried to be clever with TO_DATE and TO_CHAR functions, but I still can't figure it out. Anyone have any clever ideas?</p>