Solved

convert minutes to HH:MM

Posted on 2013-01-31
3
603 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 83

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

622 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