Solved

convert minutes to HH:MM

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

809 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