Holidays Ok, one of the things that I strive for in my ACL scripts is to write scripts that do not have to be edited year after year. Too often people will write scripts for a specific year that has to edited every year. For example, holidays are often programmed into various programs, but they are hard coded into scripts. Many holidays are hard coded. For example, in the US July 4th is always a holiday as is December 25th and January 1.
But Memorial day can be a number of different dates. It is always the last Monday of the month of MAY. This means that in 2007 Memorial day will be on May 28th. In 2006, it occured on May 29th.
Most scripts will hard code these dates into their scripts. For example:
DEFINE FIELD PwC_Holiday COMPUTED
"Thanksgiving " IF MATCH(PwC_Creation_Date,`InsertThanksgivingDate`,`InsertDayAfterThanksgiving`) "MemorialDay " IF PwC_Creation_Date = `InsertMemorialDayDate` "LaborDay " IF PwC_Creation_Date = `InsertLaborDayDate`"N/A" "N/A"
But these methods have to be edited annually or have to have long strings of dates to identify these holidays on an annual basis. It is, however, possible to write code to identify these holidays because while their date always changes, the rules dictating what date they occur is set.
Holiday COMPUTED
"Memorial Day" IF UPPER(CDOW( PwC_Entry_Date, 3)) = "MON" and SPLIT(DATE(PwC_Entry_Date),"/",1) = "05" and BETWEEN(VALUE(SPLIT(DATE(PwC_Entry_Date),"/",2),0),25,31) "Labor Day" IF UPPER(CDOW( PwC_Entry_Date, 3)) = "MON" and SPLIT(DATE(PwC_Entry_Date),"/",1) = "09" and BETWEEN(VALUE(SPLIT(DATE(PwC_Entry_Date),"/",2),0),1,7) "Thanksgiving" IF UPPER(CDOW( PwC_Entry_Date, 4)) = "THUR" and SPLIT(DATE(PwC_Entry_Date),"/",1) = "1" and BETWEEN(VALUE(SPLIT(DATE(PwC_Entry_Date),"/",2),0),22,28) ""
NOTE: This would not work for holidays such as EASTER that are dictated upon lunar events or other dates not dictated by calendars. |