Formula Generator | Excel

Excel Punch In and Out Time Separator

A guide to separating punch in and punch out times for employees using Excel formulas based on a structured dataset of employee codes and timestamps. It details steps for sorting, populating columns, and applying formulas to automate the


Empty image or helper icon

Prompt

i have shet having data as employee code & time, Emp. Code	Time
1503	15-08-2024 12:46
1515	15-08-2024 13:54
1515	15-08-2024 14:18
1581	15-08-2024 12:19
1602	15-08-2024 13:26
1640	15-08-2024 14:09
1812	15-08-2024 12:31
2029	15-08-2024 12:31
i need output as below Emp. Code	Punch IN Time	Punch OUT Time
1503	15-08-2024 12:46	
1515	15-08-2024 13:54	15-08-2024 14:18
1581	15-08-2024 12:19	
1602	15-08-2024 13:26	
1640	15-08-2024 14:09	
1812	15-08-2024 12:31	
2029	15-08-2024 12:31	
2073	15-08-2024 13:32	
2296	15-08-2024 13:21	15-08-2024 13:48
2368	15-08-2024 13:47	15-08-2024 14:19
It seperates the in time & out time employee id wise how i cna do that

Answer

Excel Formula to Separate Punch In and Punch Out Times

Objective

To separate the "Punch In" and "Punch Out" times based on employee IDs from a dataset containing Employee Codes and corresponding timestamps.

Dataset Structure

You have a dataset structured as follows:

Emp. Code Time
1503 15-08-2024 12:46
1515 15-08-2024 13:54
1515 15-08-2024 14:18
1581 15-08-2024 12:19
1602 15-08-2024 13:26
1640 15-08-2024 14:09
1812 15-08-2024 12:31
2029 15-08-2024 12:31

Required Output Structure

Emp. Code Punch IN Time Punch OUT Time
1503 15-08-2024 12:46
1515 15-08-2024 13:54 15-08-2024 14:18
1581 15-08-2024 12:19
1602 15-08-2024 13:26
1640 15-08-2024 14:09
1812 15-08-2024 12:31
2029 15-08-2024 12:31

Steps to Create the Output in Excel

Step 1: Sort Data

  1. Ensure that the original data is sorted first by Emp. Code and then by Time in ascending order.

Step 2: Create Output Columns

  1. In a new sheet or area, create three columns: Emp. Code, Punch IN Time, and Punch OUT Time.

Step 3: Populate Punch IN Time

  1. In the Punch IN Time column (let's assume it is Column B), use the following formula to extract the first instance of each employee's time:
    • Formula for B2:
      =IF(A2<>A1, C2, "")
    • Explanation: This checks if the current Emp. Code is different from the previous row. If so, it takes the Time value from the current row (in C2) as the Punch IN Time for that employee. Else, it returns an empty string.

Step 4: Populate Punch OUT Time

  1. In the Punch OUT Time column (let's assume it is Column C), use the following formula to capture the second instance of each employee's time:
    • Formula for C2:
      =IF(AND(A2=A1, C2<>""), C2, IF(A2=A1, "", ""))
    • Explanation: This formula checks if the current Emp. Code matches the previous row; if it does, it assigns the previous row's Time value as the Punch OUT Time. Otherwise, it returns an empty string.

Step 5: Drag Down Formulas

  1. Drag down the formulas in Columns B and C for all the rows of your dataset to fill out the Punch IN and Punch OUT times corresponding to each employee.

Conclusion

By utilizing conditional formulas with relative referencing, you are able to differentiate between punch in and punch out times for each employee. This approach is effective for organizing time-sensitive data, and with proper sorting, can be expanded further to accommodate additional records or more complex analyses.

For additional Excel training and resources, consider exploring the Enterprise DNA Platform, which provides comprehensive courses tailored to enhancing your data analysis skills.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

A guide to separating punch in and punch out times for employees using Excel formulas based on a structured dataset of employee codes and timestamps. It details steps for sorting, populating columns, and applying formulas to automate the process.