GetShift(Date, StartDate, Sequence)
Last updated December 17, 2002
Version: 2 | Requires: CF5 | Library: DateLib
Description:
Returns the work shift for a sequence based work schedule. Mostly used by public organizations such as fire and police depts.
Return Values:
Returns a string.
Example:
<cfoutput>
Today's shift: #GetShift(Now(), "12/31/2001", "B,A,C,A,C,B,C,B,A", 9)#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
Date | Date to return the shift for. | Yes |
StartDate | Start date of the sequence. | Yes |
Sequence | Comma delimited list defining the shift sequence. | Yes |
Full UDF Source:
/**
* Returns the work shift for a sequence based work schedule.
* v2 by Raymond Camden
*
* @param Date Date to return the shift for. (Required)
* @param StartDate Start date of the sequence. (Required)
* @param Sequence Comma delimited list defining the shift sequence. (Required)
* @return Returns a string.
* @author Rob Rusher (rob@robrusher.com)
* @version 2, December 17, 2002
*/
function GetShift(date, startDate, sequence) {
var daysDiff = DateDiff("d",startDate,date);
var key = daysDiff mod listLen(sequence) + 1;
return listGetAt(sequence,key);
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016