Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

convert minutes to HH:MM

Posted on 2013-01-31
3
Medium Priority
?
613 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

730 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