473,804 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how add totaltime = [hh:mm:ss] + [hh:mm:ss] in query

547 Contributor
how add (longtime) totaltime = [hh:mm:ss] + [hh:mm:ss] 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
Oct 16 '10 #1
11 7462
NeoPa
32,579 Recognized Expert Moderator MVP
You just add them together.

With so little background information or any sort of explanation about what you're working with I have nothing to go further with.
Oct 16 '10 #2
OldBirdman
675 Contributor
Times and dates are stored as numbers, with the fractional part as the time, and the integer part as the date. Adding 0.75 (6:00:00PM) to 0.5(Noon) results in 1.25. Formatting, whether longtime or shorttime or any other formatting is applied to display the stored data (number)in a meaningful form.
Adding two times in a query is as NeoPa suggests, just add them.
Access does not have a built-in format for displaying time as hours/minutes/seconds when the total hours exceeds 24, which is when the fractional parts sum to a value greater than 1. Therefore, this will require a user function to accept as a parameter a long number.
This function would return '31hrs 10min 20sec' or '4239hrs 0min 0sec' or ANY other valid hrs/min/sec as a string.
Remember, you are dealing with the way times are stored in the query, and the way you want the times formatted when shown.

OldBirdman
Oct 16 '10 #3
neelsfer
547 Contributor
this is what i get
TotalTime:[MultidayOneQ.Ra cetime]+[MultidayTwoQ.Ra cetime]
IDNo -----------Day1------- Day2--------TotalTime
7805085171085 --01:09:47---01:10:09-----01:09:4701:10:0 9

i get the Day1 and Day2 results by filtering the racetimingT in two separate queries (using a 1 or 2 linked to a day, that is added when race is setup). then In another query i link each day's IDNo to the IDNO from the cyclist table. This is only way i can get the records to display from "vertical to horizontal" in a query and separated per day

i added --- in the spaces
Oct 16 '10 #4
OldBirdman
675 Contributor
OK, so the times are not stored as date/time data as suggested in the original post. They are stored as text (string) data. The operand + (plus) adds numeric data, but concatinates string data. That is what is happening here. Your total time "01:09:4701:10: 09" is "01:09:47" concatinated with "01:10:09".
Therefore, what you need to do is convert these strings to date/time before adding. CDate([MultidayOneQ.Ra cetime]) + CDate([MultidayTwoQ.Ra cetime]) would add these as times, not strings. You will still have to convert this sum to your custom format.
Oct 16 '10 #5
neelsfer
547 Contributor
thx a million
if i add a day3 and day4 in calculation but there is no data in there yet, should i use Nz or? because i get datatype mismatch error in criteria expression if datafield is blank
Oct 16 '10 #6
NeoPa
32,579 Recognized Expert Moderator MVP
Nice one OB :-)

@Neelsfer - I'd suggest post #5 as the Best Answer ;-)
Oct 16 '10 #7
OldBirdman
675 Contributor
I think this is a new question, and belongs in a new thread. However, as asked, it is incomplete and would not be understood.

Your table(s) are not normalized. I see over and over suggestions by experts that this not be allowed to happen, but each poster feels is circumstance is unique, and non-normalized tables are justified. Just ranting here.

Because you are storing time as text, it is up to you to verify that the string actually represents a time. Nz() certainly will correct fields whose value is null, which is in the table design for an initial value for the field. Why not "00:00:00" instead? You don't say how the data is entered and/or verified, so you also may need other corrections.
Oct 16 '10 #8
neelsfer
547 Contributor
The CDate works to add the 00:00:00 but it stops at 12pm and start all over again. it also shows AM
03:07:10 AM + 07:00:06 AM + 04:02:42AM = 02:09:58 AM
I even appended this query into a table with longdate fields but it is still the same

The way i added it + filtered is probably why its so complicated.
Its for a 3 day cycling race. I captured it in a subform: the racedate and DayNo and racetime (calculated) are both in same table ie 1 or 2 or 3. The data is then filtered depending on the day and added up.
any suggestions pls?
Oct 18 '10 #9
OldBirdman
675 Contributor
Converting your time strings to dates using CDate is good, providing you verify that the string is a time, as I mentioned before.
But dates are stored as 64-bit (8-byte) floating-point numbers. Positive values to the left of the decimal point represent the number of days starting with 30 Dec 1899 through 31 Dec 9999. The values to the right of the decimal represent time, in fractions of a day. .5 is 1/2 of a day, or midday, and .75 is 3/4 of a day, or 6:00:00PM.
You are using date fields to represent elapsed time, not a time of a day. This is done all the time, but when you do arithmetic, you must realize that Access inteprets 0.75 as 12/30/1899 06:00:00PM. Adding this to 0.5 (012/30/1899 12:00:00PM) will result in 1.25 or 12/31/1899 06:00:00AM. Formatting as longdate does not change this, only changes what is displayed, not the underlying values.
I tried your calculation in the Immediate Window, using CDate and here Copy/Paste exactly what happened:
Expand|Select|Wrap|Line Numbers
  1. ?CDate("03:07:10 AM") + CDate("07:00:06 AM") + CDate("04:02:42AM")
  2. 2:09:58 PM 
I have no idea what you did. Actually, I have no idea what you are doing, or what you tried, or what the queries you refer to are. You have not chosen to share any code or SQL with us.
Oct 18 '10 #10

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

Similar topics

8
13035
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 the database. I've tried a few DateTime.Parse methods but can't get any to work. The format of these values in the database is yyyy-MM-dd hh:mm:ss.000
3
3006
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. When it contains datetime-columns, I want these columns formatted like SQLServer-datetimeformat 121. I don't want the query to return datetime-columns converted to strings because they are used for calculations
12
29482
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 follows: function doDateCheckNow(source, args) { var oDate = document.getElementById(source.controltovalidate); // dd/mm/yyyy
7
2776
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, here is my table structure, Name: Table1
1
2169
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 want to generate a an excell sheet of that table but here i want the time to be like mm:ss but not hh:mm:ss examle the length of song sweet dreams is 01:12:35 now i want this to be shown as 72:35 how is there any procedure to convert directly in...
2
1252
by: progvar | last post by:
Hi! i am running the query but it is showing the error of syntax, i m accessing this table from sql server & my query is squery = "SELECT * FROM New_Rec where From_Date > = " & Format(DTPFrom & " 00:00:00", "dd/mm/yyyy HH:MM:SS AMPM") & " AND To_Date <= " & Format(DTPTo & " 23:59:59", "dd/mm/yyyy HH:MM:SS AMPM") & """" In this query FROM_DATE and TO_DATE are my column names AND DTPFrom & DTPTo are DTPicter . best regards varinder
2
16806
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
2
5007
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 retrieve the time from the database the time will be like this... 2010-10-26 10:00:39 but i want only the time part. i.e 10:00:39
4
2608
by: neelsfer | last post by:
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(-,"hh:nn:ss")) = 00:51:54 if i repeat this for lap2 to determine the lap2time value Lap2Time: Nz(Format(-,"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...
0
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7642
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.