Skip to content
Advertisement

Find start date and end date from the employee time clock

I am trying to find out star date and end date for the employee time clock. Following is the example of the data I have.

Output wanted:

I have to find the start date and end date of the person based on eventtime and activitycode. The start date will be event time column and I have to calculate end date from the same column which is next eventtime in the row.

I’ve tried using lead function in T-SQL but it’s not giving me the result I want.

If anyone has some idea how to deal with this, I would really appreciate it.

Advertisement

Answer

I suspect your EventTime should be 13:00 rather than 01:00

Example

Returns

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement