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

Home Posts Topics Members FAQ

Calculating Time

8 New Member
I am currently setting up a database for work that will operate as a timesheet. I have set up multiple tables, queries, forms and reports to help this process run smoothly.

The issue that has come up deals with calculating our times. An employee would use one form based on one table to punch into a job and the time is recorded using the value [=Now()] and then will punch out of a job on a seperate form based on a seperate table which also uses the [=Now()] function.

I linked these two tables using Job #'s, Process #'s, and Employee Names. Using these three identifiers, there would be no repeats and would uniquely link the two times. This was working great until these three fields did have a repeat (say if someone punched out on a job for lunch and then back into the same job and process after lunch).

When this happens, the query that links the start times and the end times will link both start times with both end times giving me four records instead of two. (Ex: 11:30-12:00, 12:30-1:00, 11:30-1:00, 12:30-12:00)

Any suggestions?
Jul 18 '08 #1
6 2967
puppydogbuddy
1,923 Recognized Expert Top Contributor
Try using Min and Max functions in your query to give you the earliest start time and latest end time for that employee and job # for any given day.....somethi ng like this (air code for illustrative purposes):

Expand|Select|Wrap|Line Numbers
  1. Select Table1.Employee,Table1.wDate, Table2.JobNo, Table2.TimeIn,Table2.Min(TimeIn) As MinStart, Table3.TimeOut,  Table3.Max(TimeOut) As MaxEnd 
  2. From Table1, Table2, Table3
  3. Where <(Table1.Employee = Table2.Employee  {your join fields} >
  4. Group By Employee, JobNo, wDate, TimeIn, TimeOut
  5. Having TimeIn = MinStart And TimeOut = MaxEnd
  6. Order By Employee, JobNo, wDate 
Hope this helps.
Jul 19 '08 #2
Adam1331
8 New Member
Puppydogbuddy-

Using the MinStart time and MaxEnd time function works great but the problem is that it doesn't account for the time the employee was on break. So now it will calculate just one time, 11:30-1:00 and omit the 12:00 clock out time and the 12:30 clock in time. Now it comes up with a total time of 1.5 hours on the job instead of 1 hour.

I also played with the Sum function a little seeing that the Sum of the [Start Time] subtracted from the Sum of the [End Time] will give the correct time on the project with some manipulation. The issue I have with this is that because it links both start times with both end times I recieve four records instead of two and the sum function will end up to be twice what it should (Ex: 11:30 + 12:30 = 48 instead of the 24 it should be). Is there a way to place a No Duplicates rule on just the [Start Time] and [End Time] section of the query?
Jul 22 '08 #3
Adam1331
8 New Member
And actually if I could input a No Duplicates rule I could just sort the times as ascending and that would solve the issue as well.

Thanks again for your help
Jul 22 '08 #4
puppydogbuddy
1,923 Recognized Expert Top Contributor
And actually if I could input a No Duplicates rule I could just sort the times as ascending and that would solve the issue as well.

Thanks again for your help
Try using Select DistinctRow or Select Distinct in your query as discussed in this thread:

http://bytes.com/forum/thread209027.html
Jul 22 '08 #5
Adam1331
8 New Member
This doesn't seem to work for my database or my lack of experience prevents me from being able to make it work. I do have another direction I could take things if you could help me with a different problem.

Originally there were two forms. One was a [Check In Form] which recorded the information to the [In Table]. The other was a [Check Out Form] based on a query that was run on the [In Table]. The problem with this was that I couldn't find a way to record the [=Now()] function into a record pulled by a query. Is there a way to do this, maybe with a command button or action?
Jul 22 '08 #6
Adam1331
8 New Member
Thanks again for your help. I think I have it figured out. After my last post I created a macro (which I haven't done before) using the SetValue and linked it to a command button on a form that pulls the records from a query. This way I can use just one table and still use the [Now()] function. If you can forsee any problems with this let me know, otherwise thanks again for your time and help.
Jul 22 '08 #7

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

Similar topics

5
8809
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any feedback on how I might do things differently to make it either more consice, readable, or faster. ie... are there better ways to do it in Python? It won't break any records for calculating pi, that wasn't my goal, learning Python was. But it might...
0
2275
by: Kasp | last post by:
Hi there, I am trying to make an OLAP cube on a table having two columns (datetime, Number_of_times_an_event_occured). My dimension is time and I want to measure the Min and Max times an event occured over time. I have no problem in calculating Maximum occurance of events over time. However, I have some NULL values in my Number_of_times_an_event_occured column, due to which I don't see any result when I try to calculate
1
2380
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on this form. Any employee can have multiple entries in the table (key fields are EmpID and LeaveID) for multiple dates (John Doe can take 3 days annual leave, then take 3 days sick leave in any given month. I have a BeginningBalance of hours that...
3
5346
by: Miller | last post by:
Hi, Can someone tell me how to calculate MFLOPS for the following C# code (on a Pentium 4 2.0 Ghz)? for (i=0; i<n; i++) { for (j=0; j<n; j++) { for (k=0; k<n; k++)
12
2938
by: jUrner | last post by:
Hello all I have the problem of how to calculate the resolution of the system clock. Its now two days of head sratching and still there is nothing more than these few lines on my huge white sheet of paper stiring at me. Lame I know. import time
25
5031
by: Umesh | last post by:
i want to calculate the time required to execute a program. Also i want to calcute the time remaining for the execution of the program. how can i do that? pl mention some good websites for learning advanced C.thx.
25
3223
by: Blaize | last post by:
Hi, I'm having an issue trying to calculate time. Its okay if the value does not exceed 24 hours otherwise I get a date and hours listed. For example, I have a loop which looks through a table and adds up the time spent. Dim TempCount As Date Dim DEVCount As Date Do TempCount = rst!wtime
10
5253
freddieMaize
by: freddieMaize | last post by:
Hi there, I need to hit few list of sites from my application and find the response time of those site and sort them (which ever is opening first will sit at the top). I have done the same using java (server side). Now my requirement is do in the client side (AJAX possibly). I’m having two challenges. Below is what I have done so far, <script> function call() { var d = new Date(); var xmlHttp;
3
1742
by: mfaisalwarraich | last post by:
Hi everybody. I have some problem while calculating time. i have employees who are working on hourly basis. i want to calculate the time. for example if an employee start working at 11:00pm (10-November-2008) and finish his job at 8:00am (11-November-2008) then how i can calculate the time between two different dates? i used dateDiffer method but it only displays the time difference between one date. please tell me how i can do this. thank you....
4
3946
by: Missionary2008 | last post by:
Thank you in advance for your help. I'm trying to calculate the Total Time in hours and minutes to complete a job. The way we are calculating it is by taking the Fee paid and dividing that by a 1:00. In Excel - Marsh is charged $90.00 (This is pre-determined) Her job is a $25.00/hour job (This is pre-determined) The Raw Hours to complete the job is 3.6 hours (I have this already in a qry) ...
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
10583
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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...
1
7622
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
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();...
1
4301
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
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
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.