Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: Tim MeagherHey,
Sorry for the delay in replying, but it turned out that this isn't as simple as first imagined...
There isn't any function like that available in BRAINscript, and writing something of your own just using BRAINscript would be pretty difficult given problems of calculating Easter and other movable holidays.
Even then, without lookup tables, it would need to be specific for a given country.
However, with that in mind, I've put together something which should do what you want.
It's not a function as such, but a node where you can either enter the start and end date as parameters, or specify the fields from an input record containing the start and end dates.
Similarly, you can specify a parameter for the country who's holidays you want, or specify an input field in the input records which contains the country code.
In addition, you can also specify a particular region (on the Optional tab) - from a field, or as a parameter value.
Then you specify what you want the node to calculate (all in days) either:
- Weekdays in Date Range
- Weekends in Date Range
- Workdays in Date Range
- Holidays In Date Range
- Non-Holidays in Date Range
- Sundays and Public Holidays in Date Range
- Non-Sundays and Public Holidays in Date Range
Some quick web searching lead to the web service provided by kayaposoft (
http://kayaposoft.com/enrico/) for retrieving public holiday information.
Since this is hitting a web service, for the holiday information, this node won't have particularly good performance - assuming you have specified an operation where holidays are required.
It will perform a separate query for each combination of country, year and region (if specified).
Then, it will determine the number of days for the specified operation in the specified ranges.
There are probably other things that could be fixed up performance-wise, but it should do the trick at least for not huge amounts of data - or over not huge date ranges.
An example showing its usage is attached, which is parameterized to calculate the number of holidays there will be in in NRW, Germany for this year, next year, and during the world cup in Brazil next year.
This makes use of the HTTP node from the Lavastorm Analytic Library (LAL) to perform the web service requests for holiday information.
I couldn't see anything on the kayaposoft web site about terms of usage of their web service (except saying it's free) , so I assume that it's ok to use it in for such automated requests....
Regards,
Tim.
Attachments:
DateRangeCalculatorStuff.brg