Years / Months of Service for Accruals

The employee.yearsofservice and employee.monthsofservice are often used in accrual scripting for determining how much tenure an employee has. These values are based on the employees start date and return a decimal number that represents how many years / months of service they have on a date.

If an employee was hired on June 1 of 2014, then on June 1 of 2015:
  • employee.monthsofservice would be "12"
  • employee.yearsofservice would be "1"
As mentioned, this value is actually a decimal number, so for the same employee, on January 1 of 2016:
  • employee.monthsofservice would be "19.01"
  • employee.yearssofservice would be "1.58"
These keywords can be used in if statements that determine what level of accrual to pay out to the employee.

For instance, if an employee starts earning 120 hours per year after 5 years of service, bi-weekly:

if(employee.yearsofservice >=5){
     accrueup("PTO", 120 / 26, "", "", "");}


For the full context, here is how this would appear for the following policy:
  • Employees earn 120 hours after 5 years
  • 80 hours after 1 year
  • 40 hours after 6 months
  • Hours accrue at the end of each bi-weekly pay period
  • The accrual max is equal to the annual accrual amount
  • There is no vesting date and no expiration
if(reportingdate.date = reportingdate.payperiodend){
  if(employee.yearsofservice >= 5){
     accrueup("PTO", 120 / 26, 120, "", "");}
  else if(employee.yearsofservice >= 1){
     accrueup("PTO", 80 / 26, 80, "", "");}
  else if(employee.monthsofservice >= 6){
     accrueup("PTO", 40 / 26, 40, "", "");}
  else{$donothing = 0;}
}


The script begins by checking if it is the last date of the pay period, if that is true, then it moves on to check the employee's years / months of service and dole out the correct amount of PTO.

Years of Service Based On Calendar Year

The employee.yearsofservice and employee.monthsofservice‚Äč keywords will return a number based on the employee's anniversary date. However, if the policy looks at calendar years of service instead of actual years of service, you can use the following script to create a variable that is a whole number in terms of years of service.

$years = reportingdate.year - year(employee.startdate);

The line uses the year function to find out the year the employee was hired and then subtract that from the current year.

You could now use $years in your script in place of employee.yearsofservice.

Using Employee Start Date for Vesting Date

In addition to determining years of service, accruals often need to determine if the employee has completed a introductory or probationary period before being able to use their paid leave. The vesting date can be determined by adding a number of days to the employees start date.

accrueup("PTO", 80 / 26, 80, employee.startdate + 90, "");

This script line:
  • Accrues PTO in the amount of 80 hours over 26 pay periods
  • Sets an accrual max of 80 hours
  • Sets a Vesting date that is 90 days after employee's start date

Did you find this article helpful?