There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer itunes laptop mac malware motherboard mouse network networking outlook 2007 power printer problem ram restart router screen slow sound trojan usb virus vista vista 32-bit windows windows xp winxp wireless wmp
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
convert seconds to hours


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
dpmangold's Avatar
Junior Member with 2 posts.
 
Join Date: Oct 2004
Experience: Beginner
22-Oct-2004, 12:35 PM #1
convert seconds to hours
Hi, All..new to the forum.. and a fairly beginner vb programmer.

I have been trying to figure out without success how to convert a large number of seconds to hours... i have it working when the conversion does not exceed 24 hours.. but when it exceeds 24 hours the conversion is incorrect.. Below is the code I am using with a test total seconds amount of 95000 seconds (I want it converted to 26:23 as in 26 hours.. 23 minutes)

MyTotal = 95000

MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Rows - 1, 4) = Format(DateAdd("s", MyTotal, #12:00:00 AM#), "HH:nn")

this is the only code i could find to make it work.. but it only works when the seconds total less than 24 hours..
Squashman's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
22-Oct-2004, 12:55 PM #2
Wow, the power of Google. Did a google search for [b]convert seconds to hours and found this.

http://www.freevbcode.com/ShowCode.asp?ID=85
dpmangold's Avatar
Junior Member with 2 posts.
 
Join Date: Oct 2004
Experience: Beginner
22-Oct-2004, 01:32 PM #3
Thanks... I knew I should have bought their stock... plus they beat earnings today.... have a great weekend.
dsovic's Avatar
Member with 32 posts.
 
Join Date: Aug 2004
Location: Zagreb/Croatia
Experience: Advanced
24-Oct-2004, 08:22 PM #4
Quote:
Originally Posted by dpmangold
Thanks... I knew I should have bought their stock... plus they beat earnings today.... have a great weekend.
Do the math:
1 hour = 60 minutes
1 minute = 60 seconds
----------------------
1 hour = 3600 seconds

So, to convert seconds to hours make an integer division with 3600.
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
24-Oct-2004, 09:05 PM #5
Also if myTotal is constant as it appears to be, you would just set what it is in hours, in initialization. Or, if myTotal was used elsewhere for second representation, you could have another variable (myTotalInHours) if you wanted.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:51 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.