0

I have dates column in format like below 2020-06-08 03:54 , 2020-06-08 04:10

I want to calculate time difference between this in SQL dB please Sample excel data Definition Time_cmp= R_date - p_date

R_date | p_ date | time_cmp 2020-06-08 03:54 | 2020-06-08 04:10 | 16

Akshay
  • 33
  • 3

1 Answers1

1

Try one of these Db2 functions

DAYS_BETWEEN    (h,l)
HOURS_BETWEEN   (h,l)
MINUTES_BETWEEN (h,l)
MONTHS_BETWEEN  (h,l)
SECONDS_BETWEEN (h,l)
WEEKS_BETWEEN   (h,l)
YEARS_BETWEEN   (h,l)
YMD_BETWEEN     (h,l)

The functions return whole numbers. Put the higher value first to get a +ve number out.

Paul Vernon
  • 3,818
  • 1
  • 10
  • 23