How to convert minutes into months, days and minutes with a high precision?

80 Views Asked by At

I'm want to do a time convertion, and I' facing a precision problem. I'have the time in minutes, and I want to change it into Months, days, hours, and minutes formant I've did a table in excel to test my logic with the following example: I have 110008.128 minutes which should be: (2 months) + (15 days) + (12 hours) + (30 minutes)

The logic that I'm using is:

  1. Convert the minutes to months : year= minutes * (30.417*24*60) the 30.417 is for precision
  2. get the decimal result in year and : days = (year-int(year)) * 30.417
  3. get the decimal result in days and : hours = (days-int(days)) * 24
  4. get the decimal result in hours and : minutes = (hours-int(hours)) * 60

The result is getting

2.5115735717965 Months, 15.560533 days, 13.453 hours 27.17 minutes geting just the integer part 2 mon 15 days 13 hours and 27 minutes which is wrong.

Someone knows what is happening ?

Thanks a lot guys