HolidayNameByDate ( myDate )
Returns the Holiday Name matching a Date, i.e. for a calendar. A dynamic holiday list is built within for stand-alone operation.
Average rating: 4.3 (31 votes) Log in to vote
Jonathan Mickelson - Show more from this author |
HolidayNameByDate ( getAsDate ( "12/25/2010" ) )
HolidayNameByDate ( getAsDate ( "2/25/2010" ) )
"Christmas"
(blank result)
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
UPDATED: 4/6/2010
CHANGE: Added "= " literal text in front of the "exists" variable's patterncount test to correct for matching of partial dates in list, which incorrectly flagged 2/25/2010 as "Christmas", in addition to the correct 12/25/2010. Thanks to Bill Doerrfeld, for pointing out this logic problem!
WARNING COMPLEX CALCULATIONS WITHIN!
This function returns the corresponding US (can be modified for other countries) Holiday Name for the supplied Date. The list of Holidays can be found/modified/expanded in the Variable Declarations within the calculation.
The Holiday List used internally is identical to the list generated by the another separate custom fucntion which can also be used to display this list, called "HolidayListByYear ( yearNumber )" and could be substituted for the holidayList variable within the calc, if one wanted to make it dependant upon an external Custom Function. The Author opted for a stand-alone approach.
The result is null ("") if there is no match, so that it can be used as an autoenter in a calendar solution or other type of value lookup.
NOTE: This function REQUIRES the use of another custom function called: "DateByDayOccur" which performs date calculations for dates which occur on certain occurances of a day within a month, as in the example of Thanksgiving which falls on the "Fourth Thursday of November".
Output: Text - Holiday Name
Parameters: myDate - Any valid Date
Special thanks: To Dan Kaplan, of abledesign.com for distilling
many holiday/calendaring sources on the net.
Comments
Bill Doerrfeld, Seattle Apr 5, 2010 |
||
The following line: exists = PatternCount ( holidayList ; searchCrit ) ; leads to failure as 12/25/2010 and 2/25/2010 both contain the "2/25" pattern. Accordingly, you'll get Xmas day on Feb. 25th. Xmas twice a year, nice! |
||
Jonathan Mickelson Apr 6, 2010 |
||
Good catch Bill, we'd been looking into this recently as we got a couple of false hits like Thanksgiving in January! I'll be looking into updating the calc soon! If anyone beats me to it post as a comment and I'll make the update! best, JM |
||
Jonathan Mickelson Apr 6, 2010 |
||
The change has been made and updated on the site, thanks again Bill, for pointing this out! The line: exists = PatternCount ( holidayList ; searchCrit ) ; Was changed to: exists = PatternCount ( holidayList ; "= " & searchCrit ) ; |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.