Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

convert minutes to HH:MM

Posted on 2013-01-31
3
Medium Priority
?
619 Views
Last Modified: 2013-02-04
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
    Else
        mydir = 0
    End If
   
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.SetFocus
txtCTHADOD.Text = totalCT

End Sub

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
                           180(pda
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.
0
Comment
Question by:sptech
  • 2
3 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38838780
For some reason, nobody ever implements elapsed time, only time-of-day.  Elapsed time is apparently a do-it-yourself function.
0
 

Accepted Solution

by:
sptech earned 0 total points
ID: 38838784
I changed the dimmed variable totalct from date to variant and low and behold I am getting the correct display.
0
 

Author Closing Comment

by:sptech
ID: 38850522
No points, just found my own solution.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question