Converting Minutes To Hours and Minutes

Hi,

I’m trying to figure out how to write code for an easy formula you could do on a calculator but not so easy to do in code.

I want to convert a total number of minutes to show both hours and minutes. So if I had 2121 minutes, how many hours and minutes would that be?

Dim H as Single H = 2121 / 60

H will then = 35.35 hours. But now how do I parse that number and convert it to minutes? If I did it on a calculator, the equation would be

0.35 x 60 = 21 minutes

So the answer would be 35 hours and 21 minutes.

The problem is, I don’t know how to separate the 0.35 from the 35.35.

Any help would be greatly appreciated.

Use integers for this. Figure how many hour parts are in the total and then remove those hours from the total to get the minutes.

[code]dim totalMinutes As integer = 2121

dim hours As integer = totalMinutes \ 60

dim minutes As integer = totalMinutes - hours * 60
[/code]

Thanks so much Will? That worked perfectly. I really appreciate you taking the time to help. Thanks again and have a great day.

dim duration as integer = 90 dim hours as integer = duration \\ 60 dim minutes as Integer = duration Mod 60