4 Replies Latest reply on Apr 23, 2013 12:57 AM by davidp 2

    Minutes

    7688438
      Hi,

      Please find the minutes between two dates

      D1: 16-MAY-11 12.15.06.000000000 PM
      D2: 16-MAY-11 02.20.06.000000000 PM


      Thanks in advance

      K
        • 1. Re: Minutes
          BSalesRashid
          Easy.
          • 2. Re: Minutes
            ivwvi
            http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129

            check this
            • 3. Re: Minutes
              sb92075
              7688438 wrote:
              Hi,

              Please find the minutes between two dates

              D1: 16-MAY-11 12.15.06.000000000 PM
              D2: 16-MAY-11 02.20.06.000000000 PM


              Thanks in advance

              K
                1* select ( TO_DATE('16-MAY-11 12.15.06','DD-MON-RR HH24:MI:SS') - to_date('16-MAY-11 02.20.06','DD-MON-RR HH24:MI:SS'))*24*60 FROM DUAL
              SQL> /
              
              (TO_DATE('16-MAY-1112.15.06','DD-MON-RRHH24:MI:SS')-TO_DATE('16-MAY-1102.20.06',
              --------------------------------------------------------------------------------
                                                                                           595
              
              SQL> 
              1 person found this helpful
              • 4. Re: Minutes
                davidp 2
                The other answers address the issue for dates, but it looks like your data is timestamp.
                For timestamps, the subtraction gives an INTERVAL data type and you use the EXTRACT function to get the pieces. Note that this truncates the seconds, unless you do extra work to round for seconds > 30.
                select  extract(day from intvl) * 1440 + extract(hour from intvl) * 60 + extract(minute from intvl)
                from (select to_timestamp('16-MAY-11 02.20.06pm','dd-Mon-yyyy hh.mi.ssam') 
                           - to_timestamp('16-MAY-11 12.15.06pm','dd-Mon-yyyy hh.mi.ssam') intvl from dual)
                regards,
                David
                1 person found this helpful