472,951 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

Separating data by date

I have a problem with access and our time clocks. We have time clocks
that put out a .log file with the badge swipes for everybody. There is
one .log file for each day. I am pulling that data into an access
database to manipulate it. In the table I have:

FIRSTNAME | LASTNAME | BADGE# | DATE | TIME

The problem is that the time clock doesn’t differentiate between a
“clock in” and a “clock out”. It only records badge swipes. So for
each person, I could have possibly 4-6 badge swipes per day. (clock-in
in the morning, out for lunch, in from lunch, out for the day, and if
someone needs to go to the doctor or something then they would clock out
and back in for that). Each badge swipe creates a new record in the
database. The only thing that changes is the date and time. So that
means that I could have up to 4-6 records per person, per day.
What I would like to do is separate those badge swipes, (database
records), into groups of 2 based on the badge number and then have
access do the math to tell how many hours are in between each clock in
and out. Then I would like to add the totals for all of the groups for
each person together and come up with a total time on the clock for the
day. As you can probably tell, this is for time-keeping/payroll.
I know how to get access to do the math, but I can’t figure out how to
get it to separate the badge swipes into groups of 2. Is there anyone
out there with any ideas?
Thanks in advance.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
2 2401
First off, what happens when someone forgets to clock out? Doesn't that
cause a ton of problems?

Next, what happens if someone works past midnight? Then there are records in
two different files.

Assuming the above are (somehow) not issues, you could just make a recordset
of the data ordered by person and time. Then you could walk that dataset in
code grabbing the data from two records at a time.

Here are three totally untested functions (well, one plus two shells). Do
note that the cases I mentioned above, and probably some others as well, may
well be significant issues, even if they only come up very rarely. I would
think a lot about what odditites there could be in the data and test the
heck out of your code so that you make sure it takes those situations into
accout. Mine doesn't deal with them at all. And, again, I've not even tried
running this code, so do be careful.

Jeremy

Function CalcTime()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim dtmIn As Date
Dim dtmOut As Date
Dim strSql As String
Dim lngBadge As Long
Dim sngHoursWorked As Single

Set db = CurrentDb
strSql = "SELECT Badge#, Date, Time FROM tblWhatever ORDER BY Badge#, Date,
Time"
Set rst = db.OpenRecordset(strSql, dbOpenSnapshot)

lngBadge = rst!badge#
Do Until rst.EOF
'get data from first of two records in set
dtmIn = MakeTime(rst!Date, rst!Time)

'get data from second of two records in set
rst.MoveNext
dtmOut = MakeTime(rst!Date, rst!Time)
sngHoursWorked = sngHoursWorked + (dtmOut - dtmIn)

'Check if the next set belongs to the same person
rst.MoveNext
If rst!badge# <> lngBadge# Then 'it's a different person,
'so assign the hours to the old person
'and start over for the new person.
Call AddHours(lngBadge#, sngHoursWorked)
rst.MoveNext
lngBadge = rst!badge#
sngHoursWorked = 0
End If
Loop

rst.Close
Set rst = Nothing
db.Close
Set db = Nothing
End Function

Function AddHours(lngBadge As Long, sngHoursWorked As Single)
'Your code to add to the payroll, etc goes here.
End Function

Function MakeTime(strDate, strTime) As Date
'MakeTime = The results of to convert to date/time from two fields.
'This will depend on the format of the data you get in.
End Function
--
Jeremy Wallace
AlphaBet City Dataworks
http://www.ABCDataworks.com
"Riegn Man" <r1********@yahoo.com> wrote in message
news:40*********************@news.frii.net...
I have a problem with access and our time clocks. We have time clocks
that put out a .log file with the badge swipes for everybody. There is
one .log file for each day. I am pulling that data into an access
database to manipulate it. In the table I have:

FIRSTNAME | LASTNAME | BADGE# | DATE | TIME

The problem is that the time clock doesn't differentiate between a
"clock in" and a "clock out". It only records badge swipes. So for
each person, I could have possibly 4-6 badge swipes per day. (clock-in
in the morning, out for lunch, in from lunch, out for the day, and if
someone needs to go to the doctor or something then they would clock out
and back in for that). Each badge swipe creates a new record in the
database. The only thing that changes is the date and time. So that
means that I could have up to 4-6 records per person, per day.
What I would like to do is separate those badge swipes, (database
records), into groups of 2 based on the badge number and then have
access do the math to tell how many hours are in between each clock in
and out. Then I would like to add the totals for all of the groups for
each person together and come up with a total time on the clock for the
day. As you can probably tell, this is for time-keeping/payroll.
I know how to get access to do the math, but I can't figure out how to
get it to separate the badge swipes into groups of 2. Is there anyone
out there with any ideas?
Thanks in advance.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2
"Jeremy Wallace" <ab**********@AlphaBetCityDataworks.com> wrote in message news:<44********************@speakeasy.net>...
First off, what happens when someone forgets to clock out? Doesn't that
cause a ton of problems?

Next, what happens if someone works past midnight? Then there are records in
two different files.

Assuming the above are (somehow) not issues, you could just make a recordset
of the data ordered by person and time. Then you could walk that dataset in
code grabbing the data from two records at a time.

Here are three totally untested functions (well, one plus two shells). Do
note that the cases I mentioned above, and probably some others as well, may
well be significant issues, even if they only come up very rarely. I would
think a lot about what odditites there could be in the data and test the
heck out of your code so that you make sure it takes those situations into
accout. Mine doesn't deal with them at all. And, again, I've not even tried
running this code, so do be careful.

Jeremy

Function CalcTime()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim dtmIn As Date
Dim dtmOut As Date
Dim strSql As String
Dim lngBadge As Long
Dim sngHoursWorked As Single

Set db = CurrentDb
strSql = "SELECT Badge#, Date, Time FROM tblWhatever ORDER BY Badge#, Date,
Time"
Set rst = db.OpenRecordset(strSql, dbOpenSnapshot)

lngBadge = rst!badge#
Do Until rst.EOF
'get data from first of two records in set
dtmIn = MakeTime(rst!Date, rst!Time)

'get data from second of two records in set
rst.MoveNext
dtmOut = MakeTime(rst!Date, rst!Time)
sngHoursWorked = sngHoursWorked + (dtmOut - dtmIn)

'Check if the next set belongs to the same person
rst.MoveNext
If rst!badge# <> lngBadge# Then 'it's a different person,
'so assign the hours to the old person
'and start over for the new person.
Call AddHours(lngBadge#, sngHoursWorked)
rst.MoveNext
lngBadge = rst!badge#
sngHoursWorked = 0
End If
Loop

rst.Close
Set rst = Nothing
db.Close
Set db = Nothing
End Function

Function AddHours(lngBadge As Long, sngHoursWorked As Single)
'Your code to add to the payroll, etc goes here.
End Function

Function MakeTime(strDate, strTime) As Date
'MakeTime = The results of to convert to date/time from two fields.
'This will depend on the format of the data you get in.
End Function
--
Jeremy Wallace
AlphaBet City Dataworks
http://www.ABCDataworks.com
"Riegn Man" <r1********@yahoo.com> wrote in message
news:40*********************@news.frii.net...
I have a problem with access and our time clocks. We have time clocks
that put out a .log file with the badge swipes for everybody. There is
one .log file for each day. I am pulling that data into an access
database to manipulate it. In the table I have:

FIRSTNAME | LASTNAME | BADGE# | DATE | TIME

The problem is that the time clock doesn't differentiate between a
"clock in" and a "clock out". It only records badge swipes. So for
each person, I could have possibly 4-6 badge swipes per day. (clock-in
in the morning, out for lunch, in from lunch, out for the day, and if
someone needs to go to the doctor or something then they would clock out
and back in for that). Each badge swipe creates a new record in the
database. The only thing that changes is the date and time. So that
means that I could have up to 4-6 records per person, per day.
What I would like to do is separate those badge swipes, (database
records), into groups of 2 based on the badge number and then have
access do the math to tell how many hours are in between each clock in
and out. Then I would like to add the totals for all of the groups for
each person together and come up with a total time on the clock for the
day. As you can probably tell, this is for time-keeping/payroll.
I know how to get access to do the math, but I can't figure out how to
get it to separate the badge swipes into groups of 2. Is there anyone
out there with any ideas?
Thanks in advance.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


I have thought about these and other problems and have come up with
what I think is a working solution. I have got a query counting the
duplicate records in the badge number category. I then have it
checking to see if there are an even or odd number of duplicates. My
theory is that if there is an even number of dupes, then that person
must be clocked out. If there is an odd number of dupes, then that
person is still clocked in. It's kinda primitive, but it works. I
just have the query checking to see if the number of dupes divided by
2 is an integer. If it's a whole number then the number of dupes is
even. If it's a decimal number then the number of dupes is odd.
Anyway, if the number of badge punches is odd, it removes the records
and tells the user that there was an error in swiping the badge.
There will never be anyone that is clocked in after midnight, (well
there never has been anyway). I will have to deal with that if it
ever happens. I appreciate the help. I'm gonna try this and see what
I can get done.

Thanks again for all your help.
Nov 12 '05 #3

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

Similar topics

9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
12
by: Gary | last post by:
I have a backend Database with just one main table in it (no form/queries etc) The network pc's have the front end database (with all the forms, queries,macros etc). These front ends are linked...
6
by: Chad Z. Hower aka Kudzu | last post by:
I want to do this. I want my programmers to do all the code. All of it - run at server and run at client. I then want a graphic artist to make the look and the layout of the pages. The...
13
by: Michelle | last post by:
Hi all... I could use a little TLC here for understanding and not for solving a specific problem... sorry if I've got the wrong group, but I'm using VB so I figured this was the most appropriate...
8
by: Jeff S | last post by:
Please note that this question is NOT about any particular pattern - but about the general objective of separating out presentation logic from everything else. I'm trying to "get a grip" on some...
0
by: Thag | last post by:
Hi! I am currently trying to get an overview about the possibility of separating graphical data from its animations. More specifically speaking, the graphical data is made up from 3D-CAD...
3
by: samdev | last post by:
I have a table that contains records that provide the following info: vehicle type route # start time travel time end time I need to display info for all records in a query and/or report...
14
by: Gilles Ganault | last post by:
Hi One of the ways to raise performance for PHP apps is to separate static contents from dynamic contents, so that the former can be compiled once into cache. Can someone give me a simple...
5
by: ylekot88 | last post by:
I am working on an anonymous pl/sql block that is supposed to retrieve & output customer#, date & total price of each order, listed by order date in chronological order. My pl/sql statement is...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.