Print Page | Close Window

Convert Minutes to Days, Hours, and Mins.

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6882
Printed Date: 01 April 2026 at 1:14am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Convert Minutes to Days, Hours, and Mins.
Posted By: fernan82
Subject: Convert Minutes to Days, Hours, and Mins.
Date Posted: 31 October 2003 at 10:03am
Let's say I got 16548 minutes, how can I convert that to x day(s), x hour(s), and x minute(s)...

The problem is that I'm working on a server uptime script, I can get the time the server was last rebooted and format it to how many minutes the server's been up using DateDiff, but how do I convert the minutes to days, hours and minutes.

I can't use DateDiff function cuz it'll format 13 hours into a day as it rounds it, 35 minutes to an hour etc... so I'll have to work from the minutes to make it accurate...

Thanks in advance...

-------------
FeRnAN
http://www.danasoft.com/">



Replies:
Posted By: MorningZ
Date Posted: 31 October 2003 at 10:48am

i just whipped up a function that should do that for ya

if the answer is: "11 days, 48 hours, 48 minutes"

then the function i wrote is:

Function MinsToDaysHoursMins( i_mins )
     Dim intDays, intHours, intMins, temp
     temp = i_mins \ (60*24)
     intDays = temp
     temp = i_mins - (intDays * 60 * 24 )
     intHours = temp \ 60
     intMins = temp - (intHours * 60)
     MinsToDaysHoursMins = intDays & " days, " & intMins & " hours, " & intMins & " minutes"
End function



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: fernan82
Date Posted: 31 October 2003 at 11:37am
Thanks man, I appreciate it!, it's still need a little work though... isn't 48 hours a bit too much..? :-)

<edit> or sometimes the ones I've tried will display an accurate time one minute and not the next one...

-------------
FeRnAN
http://www.danasoft.com/">


Posted By: fernan82
Date Posted: 31 October 2003 at 12:02pm
It's alright, thanks, it works, it shows 48 hours cuz there's a typo on the last line and it shows the minutes for the hours.... thanks!

-------------
FeRnAN
http://www.danasoft.com/">


Posted By: dsathish78
Date Posted: 10 December 2003 at 5:14am
Originally posted by fernan82 fernan82 wrote:

It's alright, thanks, it works, it shows 48 hours cuz there's a typo on the last line and it shows the minutes for the hours.... thanks!


Posted By: dsathish78
Date Posted: 10 December 2003 at 5:15am

Boss the function has a problem. the minutes and hour are same.

It should be like :

Function MinsToDaysHoursMins( i_mins )
     Dim intDays, intHours, intMins, temp
     temp = i_mins \ (60*24)
     intDays = temp
     temp = i_mins - (intDays * 60 * 24 )
     intHours = temp \ 60
     intMins = temp - (intHours * 60)
     MinsToDaysHoursMins = intDays & " days, " & intHours & " hours, " & intMins & " minutes"
End function

 

 



Posted By: maddkat
Date Posted: 14 December 2003 at 9:11pm
Thanks for the code



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net