By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,537 Members | 2,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,537 IT Pros & Developers. It's quick & easy.

Need Ideas for Storing Time Clock information.

P: n/a
Anyone have a simple concept for the best way to store timeclock information
in a database.

I currently have my table set up like this with a typical daily entry.

tcID empID Type Date Time
1 37 'Clockin' 1/18/08 7:45:39 AM
2 38 'Clockin' 1/18/08 7:55:42 AM
3 39 'Clockin' 1/18/08 7:55:42 AM
4 38 'BreakOut' 1/18/08 10:01:00 AM
5 39 'BreakOut' 1/18/08 10:01:15 AM
6 37 'BreakOut' 1/18/08 10:03:27 AM
7 39 'BreakIn' 1/18/08 10:10:10 AM
8 37 'BreakIn' 1/18/08 10:11:01 AM
9 38 'BreakIn' 1/18/08 10:13:07 AM
10 39 'LunchOut' 1/18/08 12:00:10 AM
11 37 'LunchOut' 1/18/08 12:00:45 AM
12 38 'LunchOut' 1/18/08 12:01:27 AM
13 39 'LunchIn' 1/18/08 12:55:40 AM
14 37 'LunchIn' 1/18/08 12:57:45 AM
15 38 'LunchIn' 1/18/08 12:59:11 AM
16 38 'BreakOut' 1/18/08 03:01:00 AM
17 39 'BreakOut' 1/18/08 03:01:15 AM
18 37 'BreakOut' 1/18/08 03:03:27 AM
19 39 'BreakIn' 1/18/08 03:10:10 AM
20 37 'BreakIn' 1/18/08 03:11:01 AM
21 38 'BreakIn' 1/18/08 03:13:07 AM
22 37 'ClockOut' 1/18/08 05:00:39 AM
23 38 'ClockOut' 1/18/08 05:00:41 AM
24 39 'ClockOut' 1/18/08 05:01:12 AM

The problem I'm having is parsing out the information to calculate the time
and generate a report. I'm struggling with the logic of pulling the
information for total time in a Clockin-Clockout sequence. Currently I'm
ignoring breaks but want them logged to monitor if anyone is taking longer
breaks. We pay the 10 minute breaks so I am really only looking at Total
Time - Lunch Time (of course I will adjust the start time and end time for
the work day to 8am - 5pm as needed) Keep in mind there can be an incident
where an employee has to leave sometime and which will lead to an additional
Clockin-Clockout sequence that will have to be subtracted from the total
hours for the day or the occurrence of a missing piece of data like
forgetting to clock back in from lunch etc...

I am also not locked into this database format. This is just something I
came up with and it seemed to be a good design however it's a nightmare when
trying to calculate.

Anyone done anything like this before?

Any help is greatly appreciated.

Thanks
Charlie
Jan 18 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Jan 18, 10:42*am, "Charles May" <nu...@bidniz.comwrote:
Anyone have a simple concept for the best way to store timeclock information
in a database.

I currently have my table set up like this with a typical daily entry.

tcID * *empID * *Type * * * *Date * * * *Time
1 * * * *37 * * * * * *'Clockin' * * *1/18/08 * *7:45:39 AM
2 * * * *38 * * * * * *'Clockin' * * *1/18/08 * *7:55:42 AM
3 * * * *39 * * * * * *'Clockin' * * *1/18/08 * *7:55:42 AM
4 * * * *38 * * * * * *'BreakOut' * 1/18/08 * *10:01:00 AM
5 * * * *39 * * * * * *'BreakOut' * 1/18/08 * *10:01:15 AM
6 * * * *37 * * * * * *'BreakOut' * 1/18/08 * *10:03:27 AM
7 * * * *39 * * * * * *'BreakIn' * * *1/18/08 * *10:10:10 AM
8 * * * *37 * * * * * *'BreakIn' * * *1/18/08 * *10:11:01 AM
9 * * * *38 * * * * * *'BreakIn' * * *1/18/08 * *10:13:07 AM
10 * * *39 * * * * * *'LunchOut' * 1/18/08 * *12:00:10 AM
11 * * *37 * * * * * *'LunchOut' * 1/18/08 * *12:00:45 AM
12 * * *38 * * * * * *'LunchOut' * 1/18/08 * *12:01:27 AM
13 * * *39 * * * * * *'LunchIn' * * *1/18/08 * *12:55:40 AM
14 * * *37 * * * * * *'LunchIn' * * *1/18/08 * *12:57:45 AM
15 * * *38 * * * * * *'LunchIn' * * *1/18/08 * *12:59:11 AM
16 * * *38 * * * * * *'BreakOut' * 1/18/08 * *03:01:00 AM
17 * * *39 * * * * * *'BreakOut' * 1/18/08 * *03:01:15 AM
18 * * *37 * * * * * *'BreakOut' * 1/18/08 * *03:03:27 AM
19 * * *39 * * * * * *'BreakIn' * * *1/18/08 * *03:10:10 AM
20 * * *37 * * * * * *'BreakIn' * * *1/18/08 * *03:11:01 AM
21 * * *38 * * * * * *'BreakIn' * * *1/18/08 * *03:13:07 AM
22 * * *37 * * * * * *'ClockOut' * 1/18/08 * *05:00:39 AM
23 * * *38 * * * * * *'ClockOut' * 1/18/08 * *05:00:41 AM
24 * * *39 * * * * * *'ClockOut' * 1/18/08 * *05:01:12 AM

The problem I'm having is parsing out the information to calculate the time
and generate a report. I'm struggling with the logic of pulling the
information for total time in a Clockin-Clockout sequence. Currently I'm
ignoring breaks but want them logged to monitor if anyone is taking longer
breaks. We pay the 10 minute breaks so I am really only looking at Total
Time - Lunch Time (of course I will adjust the start time and end time for
the work day to 8am - 5pm as needed) Keep in mind there can be an incident
where an employee has to leave sometime and which will lead to an additional
Clockin-Clockout sequence that will have to be subtracted from the total
hours for the day or the occurrence of a missing piece of data like
forgetting to clock back in from lunch etc...

I am also not locked into this database format. This is just something I
came up with and it seemed to be a good design however it's a nightmare when
trying to calculate.

Anyone done anything like this before?
Just a thought, but it might be easier if you split out the Type
information to two columns, one column for In/Out and other for
Reason.
Jan 18 '08 #2

P: n/a
Charles May wrote:
Anyone have a simple concept for the best way to store timeclock
information in a database.
Better places to ask might be

microsoft.public.sqlserver.programming
comp.databases.ms-sqlserver

where there are also answers to "how do I calculate timespan"-type
questions.

Andrew
Jan 18 '08 #3

P: n/a
your current table structure is certainly not normalized and may
present replication and / or cohesion problems in the future.

in our timeclock application, the recorded time table contains a
column for each in / out instance. so there is a dayIn, lunchOut,
lunchIn, and dayOut column.

the application itself does not allow the user select which instance
they are clocking in / out for. so, if all four columns are empty,
it's assumed that the user is clocking in for the day and the dayIn
column is populated by the application. if dayIn already contains a
datetime, then the lunchOut is populated.

of course, your sql query must return a single row for the current
date.

i suppose if you're including breaks additional columns could be
created.

i found this structure the easiest when attempting to create reports.

i'm not sure if i've been thorough enough in this description so let
me know if i can help.

joe c.

On Jan 18, 7:42 am, "Charles May" <nu...@bidniz.comwrote:
Anyone have a simple concept for the best way to store timeclock information
in a database.

I currently have my table set up like this with a typical daily entry.

tcID empID Type Date Time
1 37 'Clockin' 1/18/08 7:45:39 AM
2 38 'Clockin' 1/18/08 7:55:42 AM
3 39 'Clockin' 1/18/08 7:55:42 AM
4 38 'BreakOut' 1/18/08 10:01:00 AM
5 39 'BreakOut' 1/18/08 10:01:15 AM
6 37 'BreakOut' 1/18/08 10:03:27 AM
7 39 'BreakIn' 1/18/08 10:10:10 AM
8 37 'BreakIn' 1/18/08 10:11:01 AM
9 38 'BreakIn' 1/18/08 10:13:07 AM
10 39 'LunchOut' 1/18/08 12:00:10 AM
11 37 'LunchOut' 1/18/08 12:00:45 AM
12 38 'LunchOut' 1/18/08 12:01:27 AM
13 39 'LunchIn' 1/18/08 12:55:40 AM
14 37 'LunchIn' 1/18/08 12:57:45 AM
15 38 'LunchIn' 1/18/08 12:59:11 AM
16 38 'BreakOut' 1/18/08 03:01:00 AM
17 39 'BreakOut' 1/18/08 03:01:15 AM
18 37 'BreakOut' 1/18/08 03:03:27 AM
19 39 'BreakIn' 1/18/08 03:10:10 AM
20 37 'BreakIn' 1/18/08 03:11:01 AM
21 38 'BreakIn' 1/18/08 03:13:07 AM
22 37 'ClockOut' 1/18/08 05:00:39 AM
23 38 'ClockOut' 1/18/08 05:00:41 AM
24 39 'ClockOut' 1/18/08 05:01:12 AM

The problem I'm having is parsing out the information to calculate the time
and generate a report. I'm struggling with the logic of pulling the
information for total time in a Clockin-Clockout sequence. Currently I'm
ignoring breaks but want them logged to monitor if anyone is taking longer
breaks. We pay the 10 minute breaks so I am really only looking at Total
Time - Lunch Time (of course I will adjust the start time and end time for
the work day to 8am - 5pm as needed) Keep in mind there can be an incident
where an employee has to leave sometime and which will lead to an additional
Clockin-Clockout sequence that will have to be subtracted from the total
hours for the day or the occurrence of a missing piece of data like
forgetting to clock back in from lunch etc...

I am also not locked into this database format. This is just something I
came up with and it seemed to be a good design however it's a nightmare when
trying to calculate.

Anyone done anything like this before?

Any help is greatly appreciated.

Thanks
Charlie
Jan 18 '08 #4

P: n/a
Charles,

How do you want to do it better, in my idea it is impossible.

Just registrate what happens and put there your business logic around.

Cor
Jan 18 '08 #5

P: n/a
Joe,
As I was testing this I decided to try just what you specified. But then I
came upon an employee having to leave sometime in the day for maybe an
emergency or a dr.'s appointment and returns to finish out the day. I guess
I could just create a couple of extra columns for extra Ins and outs to
cover this. I just thought that someone had an ideal way of handling it that
I might be over-looking.

Another idea I had was to create multiple tables and calculate the time in
the database between clockins and clockouts for each type. So for example I
would have the following tables:

WorkHours
WorkHoursID
EmpID
Date
TimeIn
TimeOut
TotalTime

LunchHours
WorkHoursID
EmpID
Date
TimeIn
TimeOut
TotalTime

same with breaks... anyway if I clockin and and there is an occurrence of a
clockin present for that employee and date then create a new row (this
should allow extra clock logs for a given date).

When a clock out occurs, find the clockin that occurred that doesn't have a
clockout entered and update the row with the time out and calculate the
total time.

Then I could just SELECT sum(TotalTime) from WorkHours WHERE EmpID = 39 and
Date = ... for each table and then minus any lunch time from it.

Does this make sense?

I guess my biggest problem is trying to make it idiot proof when indeed that
cannot happen. If someone forgets to clock in but then later has to leave
and clocks out. I need to just create an entry to show a missing clockin and
notify the operater to inform their supervisor. I have seen so many problems
with paperless time clocks in the past that I guess I'm just trying to
alleviate a lot of them and it's making it harder than it actually needs to
be. I actually had a guy come in to work one day and forgot to clock in.
About 35 minutes into the shift he receive an emergency phone call and asked
to leave, he was in such a rush he ran out of the office and didn't clock
out. When he returned 2 hours later he clocked in and never realized that to
the people in payroll it looked like he didn't come in until 10:45. I guess
I just need to play it by ear and get something that functions and then work
on trying to solve the worlds problems ;)

I'm going to test this over the weekend to see what I can come up with.

Thanks for the input,
Charlie

"Joe C." <js******@gmail.comwrote in message
news:6b**********************************@e6g2000p rf.googlegroups.com...
your current table structure is certainly not normalized and may
present replication and / or cohesion problems in the future.

in our timeclock application, the recorded time table contains a
column for each in / out instance. so there is a dayIn, lunchOut,
lunchIn, and dayOut column.

the application itself does not allow the user select which instance
they are clocking in / out for. so, if all four columns are empty,
it's assumed that the user is clocking in for the day and the dayIn
column is populated by the application. if dayIn already contains a
datetime, then the lunchOut is populated.

of course, your sql query must return a single row for the current
date.

i suppose if you're including breaks additional columns could be
created.

i found this structure the easiest when attempting to create reports.

i'm not sure if i've been thorough enough in this description so let
me know if i can help.

joe c.

On Jan 18, 7:42 am, "Charles May" <nu...@bidniz.comwrote:
>Anyone have a simple concept for the best way to store timeclock
information
in a database.

I currently have my table set up like this with a typical daily entry.

tcID empID Type Date Time
1 37 'Clockin' 1/18/08 7:45:39 AM
2 38 'Clockin' 1/18/08 7:55:42 AM
3 39 'Clockin' 1/18/08 7:55:42 AM
4 38 'BreakOut' 1/18/08 10:01:00 AM
5 39 'BreakOut' 1/18/08 10:01:15 AM
6 37 'BreakOut' 1/18/08 10:03:27 AM
7 39 'BreakIn' 1/18/08 10:10:10 AM
8 37 'BreakIn' 1/18/08 10:11:01 AM
9 38 'BreakIn' 1/18/08 10:13:07 AM
10 39 'LunchOut' 1/18/08 12:00:10 AM
11 37 'LunchOut' 1/18/08 12:00:45 AM
12 38 'LunchOut' 1/18/08 12:01:27 AM
13 39 'LunchIn' 1/18/08 12:55:40 AM
14 37 'LunchIn' 1/18/08 12:57:45 AM
15 38 'LunchIn' 1/18/08 12:59:11 AM
16 38 'BreakOut' 1/18/08 03:01:00 AM
17 39 'BreakOut' 1/18/08 03:01:15 AM
18 37 'BreakOut' 1/18/08 03:03:27 AM
19 39 'BreakIn' 1/18/08 03:10:10 AM
20 37 'BreakIn' 1/18/08 03:11:01 AM
21 38 'BreakIn' 1/18/08 03:13:07 AM
22 37 'ClockOut' 1/18/08 05:00:39 AM
23 38 'ClockOut' 1/18/08 05:00:41 AM
24 39 'ClockOut' 1/18/08 05:01:12 AM

The problem I'm having is parsing out the information to calculate the
time
and generate a report. I'm struggling with the logic of pulling the
information for total time in a Clockin-Clockout sequence. Currently I'm
ignoring breaks but want them logged to monitor if anyone is taking
longer
breaks. We pay the 10 minute breaks so I am really only looking at Total
Time - Lunch Time (of course I will adjust the start time and end time
for
the work day to 8am - 5pm as needed) Keep in mind there can be an
incident
where an employee has to leave sometime and which will lead to an
additional
Clockin-Clockout sequence that will have to be subtracted from the total
hours for the day or the occurrence of a missing piece of data like
forgetting to clock back in from lunch etc...

I am also not locked into this database format. This is just something I
came up with and it seemed to be a good design however it's a nightmare
when
trying to calculate.

Anyone done anything like this before?

Any help is greatly appreciated.

Thanks
Charlie

Jan 19 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.