Converting minutes to Days:Hours:Minutes

  • Thread starter Thread starter WSF
  • Start date Start date
W

WSF

Access97
I need to convert minutes to Days:Hours:Minutes (00:00:00) and have tried
the following:
Format([TATMinutes]\1440,"00") & ":" & Format(([TATMinutes] Mod
1440)/60,"00") & ":" & Format([TATMinutes] Mod 60,"00")

These are typical results.
ElapsedTime TATMinutes
00:00:14 14
00:01:44 44
00:01:48 48
00:01:06 66
00:02:53 113
00:02:10 130
00:03:36 156
00:03:09 189
00:04:20 260
00:05:06 306
00:06:39 339

Where am I going wrong here?

Any help gratefully appreciated.

WSF
 
Your problem with the hours part is that you are taking a decimal and
tounding it to the nearest integer rather than its integer part, so when you
have, say, 44 minutes:
([TATMinutes] Mod 1440)/60 = 44/60 = 0.733333333
formatting this to "00" returns 01, when you should have 00 since 44 min is
under an hour. Try:
Format(Int(([TATMinutes] Mod 1440)/60 ),"00") instead.

The same goes for your days calculation, try a value of TATMinutes between
721 and 1439 and you'll get 01 instead of 00 days. Same treatment.

HTH,
Nikos
 
Hi,



An alternative would be:


CDate( TATMinutes / 1440. )


as long as you do not exceed 24h ( and I am using a 24h convention; a
AM/PM convention may ruin the effect).



Format( TATMinutes/1440. , "hh:nn:ss" )


should do, in any conventions, since the format is imposed with a 24h
convention.




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top