Adding Flemish Seasonality to your dataset in SQL

Adding Flemish Seasonality to your dataset in SQL

One of the most challenging tasks in data mining or machine learning is how to get seasonality into the mix. Therefore I created a construct that can insert the seasonality for the Flemish part of Belgium in SQL. With some minor alterations, this can easily be adapted for the Brussels or Walloon regions.

Creating the Belgian (Flemish) national holidays in SQL

Because I could create this fast in SQL and because my initial dataset was SQL Server based, I choose to create this in SQL Server.
If we take the rules on which school holidays are created: http://onderwijs.vlaanderen.be/nl/principes-vakantieregeling, we can see that it is important to correctly determine easter.
This can be done in SQL Server using the following function:

Let’s create a worktable first:

 

Once we have found Easter, it’s easy to find the school holidays using this peace of code:

 

Because not everyone’s life is coupled with the school holidays, we also have to add the national holidays. Again, this is easily done by adding the following code:

 

And there you have them, the complete set for Flanders 😉

Enjoy!