# How to calculate Length of Service?

To calculate the length of service in Excel, you need to determine the number of days, months, or years between two dates. Here's how to do it:

## Recording employee data

1. Record the employee's start and end dates. You should click on the column (1), and type in the date (2). Repeat the 1 & 2 on all employees.

Note: It is recommended that you put the employees' names in column A to know how long they have worked for the company.

## How to calculate years of service?

To find years of service you need to use DATEDIF function. The DATEDIF function is a powerful tool that can be used to calculate the difference between two dates in a variety of units, including days, months, and years. The function is not included as a built-in function in Excel, but it can be added to your workbook by downloading and installing the Analysis ToolPak add-in from the Microsoft website.

2. Click on the column (1), type in =DATEDIF(A2,B2,"y")&" years "&DATEDIF(A2,B2,"ym")&" months" (2), and hit enter.

It should be noted that the cells can be replaced with any other cells, for example, D2:E2.

3. If you don't need to see months you can modify the fomula a bit.

=DATEDIF(A2, B2, "y")& " years" formula will provide you a number of years without the months.

It is important to note that the DATEDIF function does not consider leap years, so the result may not be accurate for calculating the length of service over a period of multiple years. To account for leap years, you can use a custom formula that calculates the difference between the two dates based on the number of days in each year.

Alternatively, you can use =INT(YEARFRAC(A2,B2)) as well.

4. In case you need more precise data try using this one:

=DATEDIF(A2,B2,"y") & " years " & DATEDIF(A2,B2,"ym") & " months " & DATEDIF(A2,B2,"md") & " days"

Such a Datedif formula will provide you with the date difference in years, months, and even days.

Still not enough? Please visit how to calculate difference in Excel.