|
Post by alincon on Dec 10, 2018 12:21:21 GMT -5
I can calculate response times in days, hours and minutes. Now I want to calculate average response times I thought I could add up days, hours and minutes separately, convert total days and total hours to minutes then add all three kinds of minutes, and divide by the count of responses then convert the result back into days, hours and minutes by dividing by minutesPerDay, and dividing the remainder by 60 that remainder s/b minutes, right? But maybe there are dll's that do these calculations in my LB program?
r.m
|
|
|
Post by Rod on Dec 10, 2018 13:49:35 GMT -5
total minutes / responses = average response time
Really quite straightforwards
|
|
|
Post by tsh73 on Dec 10, 2018 13:55:27 GMT -5
Nice task to code. So take it - or invent your own wheel 'dd hh:mi functions and demo 'tsh73 Dec 2018
print "to minutes" a$="1" print a$,toMins(a$) a$="0:25" print a$,toMins(a$) a$="1:05" print a$,toMins(a$) a$="1 2:03" print a$,toMins(a$)
'backwards print "to DD HH:MI" n1=25 print n1,toDDHHMI$(n1) n2=65 print n2,toDDHHMI$(n2) n3=1563 print n3,toDDHHMI$(n3)
print "average" s=0 a$="1 2:3" print a$ s=s+toMins(a$)
a$="10 12:31" print a$ s=s+toMins(a$)
a$="2" print a$ s=s+toMins(a$)
a$="2:15" print a$ s=s+toMins(a$)
avg=s/4 print "-----------------" print toDDHHMI$(avg)
end
function toMins (ddhhmi$) wrd1$=word$(ddhhmi$,1) wrd2$=word$(ddhhmi$,2) if wrd2$="" then 'single word if instr(wrd1$,":") then 'contains (:) dd$="0": hhmi$=wrd1$ else dd$=wrd1$: hhmi$="0:0" end if else dd$=wrd1$:hhmi$=wrd2$ end if dd=val(dd$) hh=val(word$(hhmi$,1,":")) mi=val(word$(hhmi$,2,":")) toMins=mi+60*(hh+24*dd) end function
function toDDHHMI$(mins) dd=int(mins/60/24) hh=int(mins/60) mod 24 mi=int(mins) mod 60 'just missed that! toDDHHMI$=dd;" ";str2$(hh);":";str2$(mi) end function
function str2$(n) 'to 2-digit str2$=right$("0";n,2) end function
produces this to minutes 1 1440 0:25 25 1:05 65 1 2:03 1563 to DD HH:MI 25 0 00:25 65 0 01:05 1563 1 02:03 average 1 2:3 10 12:31 2 2:15 ----------------- 3 10:12
EDIT just missed INT() in minutes - got 25 minutes (from .25 part) as average.
|
|