I wrote SQL expression in format:
select date1,date2,
cast ( Floor ( timestampdiff (4, char ( timestamp (DATE2)-
timestamp (DATE1)))/1440) as char (3))||'days' ||' '
|| cast ( Floor ( Mod ( timestampdiff (4, char( timestamp (DATE2)-
timestamp (DATE1))) , 1440) / 60) as char (3)) ||'hours'
So I am having difference in minutes and then transforming it to days and hours. Example result will be:
DATE1 DATE2 DIFFERENCE
2012-01-01 10:00:00 2012-01-03 12:00 2 days 2 hours
2012-01-03 11:00:00 2012-01-03 12:00 0 days 1 hours
This is result which I am getting at the moment and it is ok. But now I want to have seperate result with AVERAGE value for difference. So for first row number of minutes is 3000. For second row number of minutes is 60. Average value is (3000+60)/2=1530 = 1 days 1 hours
So I want result in this format: average value: "1 days 1 hours"
I am using db2. Thank you