Answer the question
In order to leave comments, you need to log in
How to write a script for employee time tracking?
Hello, tell me please!
Given a table - date , time , person , updated with new values when a person passes through the checkpoint, he can leave / come several times a day. The first entry (odd) of the day is assumed to be the arrival time, and the even one the departure time.
It is necessary to make a selection of the full name of the employee and the actual time that he spent at work for each day.
Answer the question
In order to leave comments, you need to log in
Is the table editable? I would add one more field to store there the id of the timestamp of coming to work. All even numbers will have this field zero, while odd numbers will not.
Came to work - added values
......
7 | 02.11.2014 | 11.22 | Vasily Pupkin (or his id) | 0
.....
leaving:
.....
8 | 02.11.2014 | 18.12 | Vasily Pupkin | 7 (id of the timestamp of the last entrance to the building)
.....
I would also combine the date and time fields into one field.
An example on the knee:
sqlfiddle.com/#!2/de7c1/2
For more, just sum up the resulting time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question