Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Convert Minutes to Days, Hours, and Mins.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Convert Minutes to Days, Hours, and Mins.

 Post Reply Post Reply
Author
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Topic: Convert Minutes to Days, Hours, and Mins.
    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
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post 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...

Edited by fernan82
FeRnAN
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post 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!

Edited by fernan82
FeRnAN
Back to Top
dsathish78 View Drop Down
Newbie
Newbie
Avatar

Joined: 10 December 2003
Location: India
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote dsathish78 Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
dsathish78 View Drop Down
Newbie
Newbie
Avatar

Joined: 10 December 2003
Location: India
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote dsathish78 Quote  Post ReplyReply Direct Link To This Post 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

 

 

Back to Top
maddkat View Drop Down
Groupie
Groupie


Joined: 13 December 2003
Status: Offline
Points: 154
Post Options Post Options   Thanks (0) Thanks(0)   Quote maddkat Quote  Post ReplyReply Direct Link To This Post Posted: 14 December 2003 at 9:11pm
Thanks for the code
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.