473,385 Members | 1,655 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,385 software developers and data experts.

hh:mm:ss + hh:mm:ss values in query don't add up

547 512MB
I first deducted the laptime and actualstarttime of a race in a query using this formula and it gives me a correct lap1time value

Lap1Time:nz(Format([Lap1]-[Actualstarttime],"hh:nn:ss")) = 00:51:54
if i repeat this for lap2 to determine the lap2time value
Lap2Time: Nz(Format([Lap2]-[lap1],"hh:nn:ss")) = 00:00:03
and the 3rd lap = 00:00:03

It produces the correct time

My problem is adding up these to laptimes to get a totaltime from the start. I dont want to just deduct the finaltime after the 3rd lap from the actualstartingtime, as the number of laps may vary from race to race and i therefore prefer to add up the laps. My vb programming skills are lacking here.
i think the data type is string and it is formatted as hh:mm:ss - that is the problem.

TotalTime: Format([Lap1time]+[lap2time]+[lap3time],"hh:nn:ss")

lap1time = 00:51:54 ; lap2time= 00:00:03 ;
lap3time=00:00:03

then i get = 00:51:5400:00:0300:00:03 which is a combination of lap1time+lap2time+lap3time rather than adding it up and giving you = 00:52:00
i think the data type is string and it is formatted as hh:mm:ss - that is the problem.

anybody out there that can relieve me of this unnecessary stress in my life by providing a solution? hehehe

Attached Images
File Type: jpg total1.jpg (43.8 KB, 423 views)
File Type: jpg addlap2.jpg (38.1 KB, 529 views)
Nov 26 '10 #1

✓ answered by ADezii

The following Logic should work, as long as you do not go past 24hrs. Total, but I'll leave that for you to test:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print Format$(CDate("00:51:54")+CDate("00:00:03")+CDate("00:00:03"),"hh:nn:ss")
Result:
Expand|Select|Wrap|Line Numbers
  1. 00:52:00

4 2579
ADezii
8,834 Expert 8TB
The following Logic should work, as long as you do not go past 24hrs. Total, but I'll leave that for you to test:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print Format$(CDate("00:51:54")+CDate("00:00:03")+CDate("00:00:03"),"hh:nn:ss")
Result:
Expand|Select|Wrap|Line Numbers
  1. 00:52:00
Nov 27 '10 #2
neelsfer
547 512MB
thx mr Adezii; you saved me again!!
Nov 27 '10 #3
ADezii
8,834 Expert 8TB
You are quite welcome, but after all I am a little more familiar with the DB than most (LOL).
Nov 27 '10 #4
NeoPa
32,556 Expert Mod 16PB
The general rule of keeping dates and times in DateTime format for storage and string format only for displaying values is a good one that would save you from this problem.
Nov 27 '10 #5

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

Similar topics

8
by: Assimalyst | last post by:
Hi i have a value entered into an asp text box, procedureDateTxtBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query...
3
by: jobi | last post by:
Hi, I've tried to get to this formatting stuff once, a while ago. I still didn't figure out how to format a date-column in a (data)-grid. I have a dynamic query that returns a # of columns....
16
by: Filips Benoit | last post by:
Dear all, I have a datefield that sometimes should store hours and minutes too ans use following format and inputmask. dd/mm/yyyy hh\:nn 09/09/0000\ 99:99;0;* Typing date, hour and...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
7
by: mr.nimz | last post by:
hello, this is antenio. recently i've come to a problem. i got a way through it, somehow, still it left me in a curious state, so i'm posting it here, if i can get an answer from some techy, ...
8
by: John | last post by:
Hi I am using the below code to run a sql on an underlying access table; insStr = "INSERT INTO ( Action, , , Request_Date ) " & _ "VALUES (""Modify Client"", 93, ""Administrator"", Now())"...
1
seshu
by: seshu | last post by:
Hi every body to morning my cousine has show his application and also his live db in that to sav the length of all the voice files he has saved in time format ie he took the datatype of time now i...
2
by: smitanaik | last post by:
hi i want to do validation of datetime in javascripti.e is i want it in this format dd:mm:yyyy:hh:mm:ss plz heklp me out its urgent
11
by: neelsfer | last post by:
how add (longtime) totaltime = + in query; i need to be able to add more than 24hrs also but it can still show in this format ie (hh:mm:ss) 31:10:20 = 31hrs 10min 20sec pls help
2
by: impin | last post by:
i have stored the user break times in the database... user break start time and end time... the timestamp stored in the database in the (yyyy-mm-dd hh:mm:ss) format in the database... when i...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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.