Wednesday, April 5, 2017

How does one get the time difference between two date columns SQL

How does one get the time difference between two date columns
 in hours , minutes and seconds



SELECT floor((D1-D2)*24)
      || ' HOURS ' ||
          mod(floor((D1-D2)*24*60),60)
        || ' MINUTES ' ||
        mod(floor((D1-D2)*24*60*60),60)
         || ' SECS ' time_difference
    FROM honnikery;



TIME_DIFF
--------------------------------------------------------------------------------
1 HOURS 0 MINUTES 0 SECS
1 HOURS 10 MINUTES 0 SECS
10 HOURS 1 MINUTES 10 SECS

No comments:

Post a Comment