Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

minutes calculate

Status
Not open for further replies.

eshaan

Technical User
Feb 20, 2003
57
US
How can I add minutes into hrs if minutes more than 59 in report?
I created report that is calculating minutes . I created grand total. In grand total it is showing 59.82. Last two digits are more than 59 it has to be add into hrs.

ex: 59.82= hrs60.32mts.


Any idea?

 
You said, I created report that is calculating minutes but it looks like you're calculating hours and minutes.

If you calculated minutes only, you could use an expression like:

Hours = ([myTotalMinutes] - ([myTotalMinutes] Mod 60))/60
Minutes = [myTotalMinutes] Mod 60


HTH


John

Use what you have,
Learn what you can,
Create what you need.
 
How would "ex: 59.82= hrs60.32mts"?
59.82 should be 59:49


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I presume "59.82" means 59 minutes and 82 seconds?

Ed Metcalfe

Please do not feed the trolls.....
 
If so something like this should do the job. Sorry, no error trapping - you'll need to test and add your own accordingly....

Public Function FormatTime(ByVal dblTime As Double) As String
Dim intNoOfHours As Integer
Dim intNoOfSeconds As Integer

intNoOfHours = Left(dblTime, InStr(1, CStr(dblTime), "."))
intNoOfSeconds = Right(CStr(dblTime), Len(CStr(dblTime)) - InStr(1, CStr(dblTime), "."))

If intNoOfSeconds > 59 Then
intNoOfHours = intNoOfHours + CInt(intNoOfSeconds / 60)
intNoOfSeconds = intNoOfSeconds Mod 60
End If

FormatTime = intNoOfHours & " hours " & intNoOfSeconds & " seconds."
End Function

Ed Metcalfe

Please do not feed the trolls.....
 
hmmmmmmmmmmmmmmmmmmmmm ... mmmmmmmmmmmmmmmmmmm

0.83 minutes ~~ 42 seconds, so -ASSUMING- this is actually minutes the 59:49 (M:S) = 59.82 Minutes is correct.

might be interesting to see the actual expression which returns "59.82" ... have seen some many of these excursions go a lot wild, but regardless, there are easies ways to get to the truth.

By simple reasoning, there are 60 minutes in each hour and 24 Hours in a day, so htere are 1440 Minutes in a day. A direct approach to solving:

Code:
? format(59.82 / 1440, "h:m:s")
0:59:49

On the other hand the prior calcuilation is of interest, as minutes can ONLY be expressed as portions of one hour, so many (most) attempts to sum minutes over a recordset will return a value > 60. Ms. A. "date/time" expressions will truncate the leading portion (Hours?) and return JUST the minutes, so in many instances the value would be some number of hours + hte minutes ...




MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top