title: Timestamp subtraction
body: <p>I am getting the error</p>
  
  <blockquote>
    <p>PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got INTERVAL DAY TO SECOND</p>
  </blockquote>
  
  <p>When I try to run this procedure. The column <code>EXPIRES</code> in the code below is of type TIMESTAMP(6) in the SESSIONS table. As far code is concerned I am having two consistent datatypes being subtracted from  each other. So why this error?</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE demo_restrict_multlogin (p_login       varchar2,
                                                       p_out     OUT NUMBER,
                                                       p_msg     OUT VARCHAR2)
  IS
     vl_val    NUMBER;
     vl_diff  TIMESTAMP(6);
  BEGIN
     p_out := 0;
  
     SELECT   SYStimestamp-EXPIRES
       INTO   vl_diff
       FROM   sessions
      WHERE   LOGIN_DETAILS = p_login;
  
  
     SELECT   CASE WHEN COUNT (1) &gt; 0 THEN 1 ELSE 2 END
       INTO   vl_val
       FROM   sessions
      WHERE   LOGIN_DETAILS = p_login AND TO_CHAR (vl_diff, 'mi') &gt; 30;
  
     IF vl_val = 1
     THEN
        p_msg := 'Pass expired';
     ELSE
        p_msg := 'Pass not expired ';
     END IF;
  EXCEPTION
     WHEN OTHERS
     THEN
        p_out := 1;
  END;
  </code></pre>