guys need your help here... pls

I am trying to monitor the timings of the employees everytime they used their ID. So in 1 day they might swipe the ID many times.
what i did is get the time difference (date,hour & minutes) for 2 dates.
date format: 02-Feb-2014 10:31
1st formula is:
local numbervar tt := datediff('n',{IDswipe startdate},{IDswipe enddate});
local numbervar d := truncate(tt/1440,0);
local numbervar h := truncate(remainder(tt,1440)/60,0);
local numbervar m := truncate(remainder(tt,60),0);
local stringvar tt_d := if d=0 then "" else totext(d,0,"") + 'd ';
local stringvar tt_h := if h = 0 then "" else (totext(h,0,"")) + 'h ';
local stringvar tt_m := totext(m,0,"") + 'm ';
local stringvar tt_string := tt_d & tt_h & tt_m
Result of the formula : ex. 2d 17h 22m
2nd formula : {IDswipe enddate} - {IDswipe startdate}
Result = 1.5 (meaning 1 day and 12 hrs.)
Both formulas are successful
here is the tricky part: I want to get the summary of all time differences and Average per Employee. How can i do this? Using the Insert Summary/Averrage does not get the correct numbers. I am having difficulty in creating formula to get the Summary and Average per Employee.
FYI - all the details are in GROUP HEADER
will really appreciate your help

