Home      Ask a Question      My Stuff      Help   
  
Scripting - Changing or Excluding Hours from Changing that Cross Midnight to Another Category.
Sometimes clients want all hours worked on a certain day to be categorized as something else.

That can prove to be a problem for employees that work shifts that cross midnight as by default our system keeps all punches to the day of the first in punch even if it crosses midnight which could exclude or include hours not intended.

As an example of a possible issue and resolutions for it a client wants all Sunday hours from 12:00am t0 11:59pm to be a category of "Sunday".

Next we have an employee that works a continuous shift (no breaks) from 10:00pm to 3:00am from Sat-Fri.

So on Saturday because of our system all their hours including hours that cross midnight (12:00am to 3:00am) are still counted for Saturday. So in effect it disregards 3 hours that should be categorized as "Sunday".

With a script though (see below) we can make those Sunday hours (12:00am to 3:00am) change to "Sunday" as it should:

if ("S" contains weekday (punchdate))
{
split (12:00am);
}
if (intime = 12:00am)
{
category = "Sunday";
}

This script states that:

1. If it is "S" or Saturday then make a split at 12:00am (or on Sunday) which creates an out punch then an immediate in punch at midnight.

2. Next if it sees an in punch of 12:00am as our split creates then make all hours after that point category "Sunday".


Our next example shows how to have it exclude hours. Using the same employee we know that they also work Sunday and the shift crosses into Monday (12:00am to 3:00am) which our client does not want included and changed to our "Sunday" category but remain as "Regular" time.

So what we can do through scripting is to sort of reverse our above script.

In our below example script if it is Sunday we have it react to Monday first then Sunday:

if ("U" contains weekday (punchdate))
{
split (12:00am);
if (intime = 12:00am)
{
category = "Regular";
}
else
{
category = "Sunday";
}}

So in our script it states that:

1. If it is Sunday ("U") first split 12:00am or Midnight.

2. Next if the in time is equal to 12:00am (which was created by our split) then make all hours after that category "Regular" or the default category as these are Monday hours.

3. Lastly we use the "else" keyword next that states if their in time does not equal 12:00am or in other words any hours that are worked before Midnight then change the category to "Sunday".

A side note on this, as with any shift that crosses midnight and since our system does not order times chronologically from punch to punch but strictly on the time value of the punches when crossing midnight it will be out of sequence as the system will always take the lowest value and enter it first which our split creates (12:00am).

The way the system distinguishes this for read ability is to add a "+" in front of the time to signify +1 day or the next day or for our example +12:00am.

Attached is a screen shot of this working for both of our examples (Sat to Sun and Sun to Mon) as well as the above noted "+12:00am" times out of sequence:



ID
458
Category
Training
  FAQ's
Date Created
1/19/2010 12:57:39 PM
Date Updated
1/20/2010 7:03:25 AM
Back to Search Results