Holiday Worked and Holiday Hours Scripting - TWP

This article covers:
In most cases, these scripts will be entered in the PayRateScript box. That is found in the Settings Menu > Processing Rules > Scripting category.

Change Regular Hours to Holiday Worked

Do a category change to a "Regular" punch in TimeWorks Plus and change it to "Holiday Worked" based on if that day is a holiday AND that employee actually worked that day:

if (reportingdate.isholiday AND istimes){
    category = "Holiday Worked";


The istimes condition insures that this script only runs if the employee used the clock. It will prevent the script from running on an hours entry like Vacation or Sick.

To change the pay rate as well, do the same as in the previous example (change a category to "Holiday Worked") AND change the pay rate to the default pay rate times time and a half:


if (reportingdate.isholiday AND istimes){
   category = "Holiday Worked";
   payrate = val(employee.payrate0) * 1.5;

Add Holiday Hours to Holiday Worked Hours

The "HolidayRule" Processing Rule allows one to add paid Holiday hours to a time card. Unfortunately if the employee also works that holiday the rule defaults to the worked hours and does not auto add hours to the time card. If the client would like to see both Regular/Holiday Worked hours on the time card as well as 8 hours of Holiday pay, the following scripting will accomplish that.

This script will go in the AddEntryScript rule box.
if (reportingdate.isholiday){
   addentry("hours", 8, "Holiday");

The script uses the reportingdate.isholiday keyword to see if the time card date matches a designated holiday (done through the Holiday Rules) and if yes, it uses the addentry function to create a new time card line with the Holiday hours.

addentry takes three arguments in the following order:
  • type - either hours or amount surrounded by quotes
  • numeric value - in this case, we are adding 8 hours
  • category - this would be the Punch Category of the entry, which must be contained in quotes and match a category in the Punch Categories rule
Prior to October of 2015, this was often done with a Split Post Reporting Date script. If you currently have a script like that in place on your account and would like to see details as to why it works, please see Add Holiday Hours - Split Post Reporting Date Method.

Holiday Hours for Employees with 90 Days of Service

It's not unusual for employers to only pay holiday hours to employees that have passed a probationary period. In this scripting example, addentry will be used to add 8 hours of holiday pay to any employee that has been employed for more than 90 days.

This script goes in the addentry script processing rule, which is found in the Scripting category on the Processing Rules page.

if(reportingdate.isholiday and employee.daysofservice > 90){
  addentry("hours", 8, "Holiday");}

This script uses reportingdate.isholiday to determine if the day is a holiday (recognized by either the USHolidays, CustomHolidays or Holiday configuration rule) and then checks if the days of service are greater than 90. If both conditions are true, it uses addentry to add 8 hours of Holiday to the time card.

Changing Holiday Rule Hours

The HolidayRule allows you to create a default amount of hours paid out automatically for employees that do not work holidays. TimeWorks Plus: Holiday Rule Based on an identifier in Employee Setup, you can adjust those hours using scripting under the PayRateScript rule to something different or even remove those hours altogether.

In our example we set the default to 8 hours in the Holiday Rule and, based on an identifier in Home 3 of employee Setup, make adjustments to the 8 hours based on whether the employee is Part Time or within a probationary period.

In the script below, we check if the hours meet the following criteria:
  1. If the day is a holiday 
  2. There is an hours only punch present that is equal to 8 hours
  3. Is the category for that punch "Holiday"
  4. If the employee with this punch has "PT" in Employee Setup Home 3. If so adjust the hours from 8 to 6 hours

if(reportingdate.isholiday and ishours and hours = 8 and category = "Holiday"){
    if(employee.home3 ="PT"){
        hours = 6;}

The next script will do everything the first script did, but also zero out the hours for employees with less than 90 days of service.

if(reportingdate.isholiday and ishours and hours = 8 and category = "Holiday"){
    if(employee.home3 ="PT"){
        hours = 6;}
    if(employee.daysofservice <= 90){
        hours = 0;}


Because of the way the previous script is structured, it will also apply to PT employees who have less than 90 days of service. First the script will change their hours to 6, but then, after it checks their days of service and sees they are ineligible for Holiday hours, it will zero out the hours.

Exclude Weekends from AutoHoliday Hours

The Holiday Rule will apply hours to any company recognized holiday. However, if a holiday falls on a weekend and the client does not want to pay holiday hours in that circumstance to remove the hours from the time card.

In this example script, we are operating under the following situation:
  • The account has holidays designated through one of the Holiday Rules (i.e. USHolidays, Custom Holidays, etc.)
  • The client has the Holiday Rule setup to add 8 hours to the time card for any employee that does not work the holiday
  • The client does not pay holiday hours if the holiday falls on a Saturday or Sunday
  • If the script recognizes that there is an 8 hour entry on a holiday, the hours will be changed to 0
if(reportingdate.isholiday and "SU" contains weekday (punchdate)){
     if(ishours and hours = 8 and category = "Holiday"){
          category = "Regular";
          hours = 0;

Scripting Based on Day Before/After Holiday

Note this only works in TimeWorksPlus. What the script does is confirms that the day on which it is running is the day before the holiday or the day after. If it is determined to be true, we can then script additional commands based on its findings.

To do something on the day after a holiday:

if(reportingdate.isholiday( - 1)){...}

reportingdate.isholiday is checking if the day prior to the selected day on the time card was a holiday. It does this by running the isholiday logic on the minus one day. If it is, then the script will execute any following commands between the braces, {}..

To do something on the day before a holiday:

if(reportingdate.isholiday( + 1)){...}

Did you find this article helpful?