473,473 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to calculate the difference between the values of two fields containing times

33 New Member
Hi,
Using MS Access 97, i have a query over an As/400 which returns a number of fields. Within each record returned, two fields are of numeric data type but contain values relating to time.
The first field contains the start time, the second field contains the finish time.

Within my query, I need to calculate the the difference bewteen the two in order to ascertain the duration.
Finish Time minus Start Time dosent work as the value isnt calculation hours/minutes.

Any advice
Mar 2 '09 #1
4 3832
OldBirdman
675 Contributor
Your table contains Start and End times as numeric and not date/time fields. How are you storing these times? What units are assumed (hours, minutes, etc.) for these fields? What would be typical values for these fields?
Mar 2 '09 #2
Quizzed
33 New Member
Hi,
Im not actually storing them within a table, only capturing them from the as/400.
As you expected, ref the units, HHMMSS
Typical Values would be;

From Time of 181005
To Time of 192707

tks

@OldBirdman
Mar 2 '09 #3
OldBirdman
675 Contributor
I'm not familiar with as/400. I may have responded to something I can't do.
You're using Access, so either you will be running a query on your "incoming" data, or you will have fields on a form.
Either way, the Access function CDate("18:10:05") returns 6:10:05 PM, so the logic here might be:
Expand|Select|Wrap|Line Numbers
  1. Public Function TimeDiff(strStartTime As String, strEndTime As String) As String
  2. Dim dteEndTime As Date
  3. Dim dteStartTime As Date
  4. Dim lngElapsedMinutes As Long
  5.  
  6. dteEndTime = CDate(Mid(strEndTime, 1, 2) & ":" & Mid(strEndTime, 3, 2) & ":" & Mid(strEndTime, 5, 2))
  7. dteStartTime = CDate(Mid(strStartTime, 1, 2) & ":" & Mid(strStartTime, 3, 2) & ":" & Mid(strStartTime, 5, 2))
  8. lngElapsedMinutes = DateDiff("n", dteStartTime, dteEndTime)
  9. TimeDiff = lngElapsedMinutes
  10. End Function
Code might be needed to round seconds to minutes, or convert to an HHMMSS or HHMM format.
Mar 2 '09 #4
Quizzed
33 New Member
Tks Birdman, much appreciated. Query works a treat.
Mar 2 '09 #5

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

Similar topics

1
by: Andrew | last post by:
1) I have mySQL 3.23 installed. I have a record with two date/times fields in YYYY-MM-DD HH:MM:SS format. How do I find the difference between those two date/times? (I would also like to know it...
1
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number...
5
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but...
13
by: My4thPersonality | last post by:
I am reading something about the details of C#, and I came acros the statements readonly and const. I do not understand, it seems to be the same, what's the difference? Here is the text were it...
8
by: helpless | last post by:
Access 2003 - I am trying to calculate the difference between a specific date 5/1/2007 (not in a data field) and other dates that ARE in a field called Birth Date. I am trying to have it fill into...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
5
by: Bubba | last post by:
I have a dynamic pulldown list (ASP with javascript) that when a user picks a state, the corresponding counties for that state appear in a dynamic second pulldown list. When I submit the form, the...
9
by: howzit | last post by:
I have a set date in my MySQL database that records when a Sales Lead is established and I echo that date as $row_rsLead; I need to be able to calculate how many days that lead has existed....
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
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...

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.