convert minutes to HH:MM
Posted on 2013-01-31
I am trying to gather the total elapsed time when a user travels. My code SORT OF works, but instead of return HH:MM i am getting HH:MM:SS AM/PM.
pda, arrvtime, minutes, totalmin dimmed as intergers
Private Sub cmdCCT_Click()
' used to determine if traveler traveled on a non workday
If frmWD.Value = 1 Then
mydir = -480
mydir = 0
pda = 180 ' 3 hours before departure on flight
arrvtime = txtATAROD.Value * 60 'determines time from airport to site
minutes = DateDiff("n", [txtTDOTDY], [txtTAOTDY]) 'time of flight departs - time flight arrives
totalmin = arrvtime + minutes + pda + mydir ' total elapsed time in minutes
totalCT = Format(totalmin \ 60, "0") & ":" & Format(totalmin Mod 60, "00")
txtCTHADOD.Text = totalCT
As an example flight departs 08:00
flight arrives 18:00
elapsed time 10 hours or 600 minutes(datediff function)
takes 90 minutes to arrive at job site
so totalmin = 180(pda)+90(arrvtime)+minutes or totalmin = 870.
totalct dimmed as date (tried interger, long, double but kept getting type mismatch error)
when I use this: totalCT = Format(totalmin \ 60, "0") & ":" & Format(totalmin Mod 60, "00") the result is 2:30:00 pm what I need is to show the total elapsed Hours and Minutes and not 2:30:00 pm.