473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Converting Seconds Minutes and Hours

5
Hi All
My first posting.
I have three fields in an access database that are seconds,minutes and hours.These are just numbers and have no time values.I need to be able to convert these fields into proper time values.
Thanks
Bartb
Jul 20 '06 #1
3 5009
comteck
179 100+
You need to give more detail than this.

comteck
Jul 21 '06 #2
Bartb
5
Hi All
when seconds Minutes and hours are added the following result is given
SumOfHRS DUR SumOfMINS DUR SumOfSECS DUR
1530 641285 8460287
I need to be able to covert these into proper times and not just figures
Thanks
Bartb
Jul 21 '06 #3
comteck
179 100+
Most of it is formulas. For the 3 values you gave me (SumofHRS, SumOfMINS, and SumOfSECS), I just set them as constant values in the code. You may have to make a minor change, depending on how those values are set up on the form (i.e textboxes, etc).
The "Fix" Function is used to remove everything after the decimal point.
As well, "Result" is the name of the textbox that is used for the final answer. If yours is named something else, make sure you change it in the code (i.e "Me.Result=....").
Anyway, here is the code. I tested it, so I know it works.


Private Sub Command2_Click()
Dim SumOfHRS, SumOfMINS, SumOfSECS As Double
Dim SumOfDAYS, HRSRemainder, NewSumOfHRS, MINRemainder, NewSumOfMINS, SECRemainder As Variant

SumOfHRS = 1530
SumOfMINS = 641285
SumOfSECS = 8460287

NewSumOfMINS = Fix(SumOfSECS / 60) + SumOfMINS
SECRemainder = SumOfSECS - (Fix(SumOfSECS / 60) * 60)

NewSumOfHRS = Fix(NewSumOfMINS / 60) + SumOfHRS
MINRemainder = NewSumOfMINS - (Fix(NewSumOfMINS / 60) * 60)

SumOfDAYS = Fix(NewSumOfHRS / 24)
HRRemainder = NewSumOfHRS - (Fix(NewSumOfHRS / 24) * 24)

Me.Result = SumOfDAYS & " Days, " & HRRemainder & " Hours, " & MINRemainder & " Minutes, " & SECRemainder & " Seconds"

End Sub

comteck
Jul 21 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Kription | last post by:
Hello, I am having a nightmare of a time getting seconds converted to hour-minute-seconds I have a third party application that outputs only in seconds since so if someone has been logged...
7
by: Stu | last post by:
Is there a simple function call within "C" that I can use to convert number of seconds (keep in mind this may be a type longlong and has to work on UNIX and NT) into Days, months, Hours, Minutes...
5
by: Masahiro Ito | last post by:
I have column of data that have elapsed time in minutes. For example: 1:15 1:47 23:12 I like to be able to use sql server to do simple math functions. Does anyone have a simple...
6
by: Harlin Seritt | last post by:
I would like to take milliseconds and convert it to a more human-readable format like: 4 days 20 hours 10 minutes 35 seconds Is there something in the time module that can do this? I havent...
2
by: Harlin Seritt | last post by:
How can I take a time given in milliseconds (I am doing this for an uptime script) and convert it to human-friendly time i.e. "4 days, 2 hours, 25 minutes, 10 seonds."? Is there a function from the...
8
by: vunet.us | last post by:
How can I convert today's time (9:30:00) to seconds (34200) without using calculations like (9*3600)+(30*60)+0? Is there an easy function? Thank you
1
by: markdp | last post by:
I'm trying to write a program that takes a user inputted number of seconds and converts it into hours, minutes and seconds. So for instance, the program prompts the user for seconds, lets say 1000...
3
by: Bert Murphy | last post by:
Im trying to write code that would have seconds for the input,convert the seconds to the hours:minutes:seconds,accumulate the hours:minutes:seconds to a maximum of 999Hours:59Minutes:59Seconds as...
6
by: alexs | last post by:
hi, I'm moving a mysql database over to using db2 V9.5 The database is used by our radius server to store network accounting information from our switches. One parameter is the length of a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.