473,804 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calulate time between different records

I'm tryin to calculate de difference of time between different records and
fields.

I have a Report with date, time In, and Time Out fields.
EX:
Date Time IN Time Out
4/12/05 12:10 PM 12:40 PM
4/12/05 12:50 PM 1:20 PM
4/12/05 1:15 PM 1:45 PM

4/13/05 9:00 AM 9:35 AM
4/13/05 10:00 AM 10:20AM

I need to calculate the difference between Time In and Time Out. The
difference between the first time Out and the second Time IN (4/12/05 12:40
PM and 4/12/05 12:50 PM) then the second Time Out and third Time In(4/12/05
1:20 PM and 4/12/05 1:15 PM). Also the differencebetwe en First Time In and
Second Time In ...(4/12/05 12:10 PM and 4/12/05 12:50 PM)

If anybody have ideas how to aproach this i would appreciate it.
Thanks, Viviana
--
Message posted via http://www.accessmonster.com
Nov 13 '05 #1
2 2771
Viviana R via AccessMonster.c om wrote:
I'm tryin to calculate de difference of time between different records and
fields.

I have a Report with date, time In, and Time Out fields.
EX:
Date Time IN Time Out
4/12/05 12:10 PM 12:40 PM
4/12/05 12:50 PM 1:20 PM
4/12/05 1:15 PM 1:45 PM

4/13/05 9:00 AM 9:35 AM
4/13/05 10:00 AM 10:20AM

I need to calculate the difference between Time In and Time Out. The
difference between the first time Out and the second Time IN (4/12/05 12:40
PM and 4/12/05 12:50 PM) then the second Time Out and third Time In(4/12/05
1:20 PM and 4/12/05 1:15 PM). Also the differencebetwe en First Time In and
Second Time In ...(4/12/05 12:10 PM and 4/12/05 12:50 PM)

If anybody have ideas how to aproach this i would appreciate it.
Thanks, Viviana

Check out DateDiff. You can get the minutes, seconds, hours between two
times.

Regarding the differences between the first time in and the next time
in, I'd probably cheat, break rules, and I really wouldn't care if some
programmer came behind and snorted and said it wasn't following some
relational rules. I would create a new field called PriorTimeIn. When
I add a record, I would check for the max date/time for that day and
store that time into that field. Then I'd have one record with the
prior time in so I could calc the time diffs for timein's and I could
calc the diff between timein/out.
Nov 13 '05 #2
Viviana R via AccessMonster.c om wrote:
I'm tryin to calculate de difference of time between different records and
fields.

I have a Report with date, time In, and Time Out fields.
EX:
Date Time IN Time Out
4/12/05 12:10 PM 12:40 PM
4/12/05 12:50 PM 1:20 PM
4/12/05 1:15 PM 1:45 PM

4/13/05 9:00 AM 9:35 AM
4/13/05 10:00 AM 10:20AM

I need to calculate the difference between Time In and Time Out. The
difference between the first time Out and the second Time IN (4/12/05 12:40
PM and 4/12/05 12:50 PM) then the second Time Out and third Time In(4/12/05
1:20 PM and 4/12/05 1:15 PM). Also the differencebetwe en First Time In and
Second Time In ...(4/12/05 12:10 PM and 4/12/05 12:50 PM)

If anybody have ideas how to aproach this i would appreciate it.
Thanks, Viviana


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Viv, The solution could be like a running-sum query.

You can do this in the query that feeds the report (the Report's
RecordSource). I don't know what your DB schema looks like, but, if all
the data is coming from one table, the solution would look something
like this:
SELECT DISTINCT C.work_date, C.time_in, C.time_out,
DateDiff("n", P.work_date + P.time_out, C.work_date + C.time_in) As
down_time,
DateDiff("n",P. work_date + P.time_in, C.work_date + C.time_in) As
interval_time

FROM TimeSheet As C LEFT JOIN TimeSheet As P
ON C.work_date >= P.work_date AND C.time_in > P.time_out

ORDER BY C.work_date, C.time_in

WHERE < your criteria >

The C table is the current work_date table and the P table is the
previous work_date table.

The first DateDiff() calculates the minutes between the previous
record's time_out and the current record's time_in. The 2nd DateDiff()
calculates the minutes between the current record's time_in and the
previous record's time_in.

Becaue the JOIN's ON clause will cause a NULL record when the time
changes from PM to AM over a day boundary, the down_time & interval_time
will be NULL. Hopefully, you don't want to count the minutes between
end of day and beginning of next day, 'cuz I can't figure out how to get
that, yet.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQtcR34echKq OuFEgEQLjuQCgsf WzfJgH0aLH6t34P t/fPqtuqOsAn1XR
7t3RW4/SDvr6bjDF3of5eR dQ
=dAt/
-----END PGP SIGNATURE-----
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3050
by: intl04 | last post by:
I was told by an instructor of Oracle SQL that an MS Access database cannot be used to have several people enter records at about the same time, that the database will "freeze up" as a result - meaning, it'll lock out everyone else until the first person who got to the database (via a Web application, for example) is done updating his or her record. He was saying that only one update can be done at a time to an Access database. However,...
43
2149
by: Mike MacSween | last post by:
Or something to do with Nulls in PK. Which is obviously wrong. OK, after a diversion of having to earn money its back to the free one. The orchestral management system. At the E-R level: An event (concert etc.), a player (of musical instruments), an ensemble (orchestra, band et al), an instrument.
5
4307
by: Javier | last post by:
I have a field type Date/Time that automatically defaults to Now(). I'm having a problem writing a query that will retrieve all the records for a specific date the user to enters when prompted. I could retrieve all the records for a specific date if I hard-code the date into the query, but not if I want to prompt the user. Has anybody else experienced this? Does anybody have any suggestions?
1
6976
by: jj | last post by:
This is strange, I've got an Access database developed that transfers records to and from a remote database via Linked Tables/ODBC. It works fine when connected to the development server. Same Access database pointed to the production database server adn it returns this error after a short period of time. It's not like it dies right away, it'll transfer say 2000 of 4000 records, try again and it'll transfer 1000 or 4000 records. So...
3
2726
by: luscus | last post by:
Thanks for all the responses on my first question. Unfortunately the answers I was given were too complicated for my small brain , and neophite condition to understand. So if you could talk down to me and write in easier terms I would be very gratefull to all you access wizards! Here is my problem. I have a table with maybe 10 fields, It is used to imput information taken over the phone to solve patient problems in our Spanish...
2
4421
by: JHNielson | last post by:
I have a coupe of queries where I use the Time() function. Later I need to match these records to each other. But I have a certain situation where the queries are run on different records at barely different time (a few seconds apart). So the records end up not matching to each other. So I would like the function to round to the nearest minute so that they will still match. How do I do this? I have tried format(tim(), "HHNN"). but I...
3
2383
by: happiness4all | last post by:
how to calulate crc of an executable file
3
1974
by: tdes42 | last post by:
I believe I am looking for some form of Join Query, but my understanding of Access logic and my logic do not yet click entirely…. I have a table of ocean buoy data, taken every hour over many days (hopefully a whole year if it doesn’t slow things down too much): tblBuoy Date Time Swell Direction Swell Period Swell Height 5/6/2007 15:00 195 14.2 2.568
3
3911
by: camarun20 | last post by:
Hi , I constructed an MS access query in java to retrieve the rows in random. The code snipet Connection con = DriverManager.getConnection( database ,"",""); Statement s = con.createStatement() strQry = "select top 10 S_No , Rnd(S_No) as exp from Questions order by Rnd(S_No) desc" ; s.execute(strQry) ;
0
9706
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
9582
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,...
0
10335
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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,...
0
10082
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
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();...
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
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.