DEV Community

Discussion on: Adding business days to a date using SQL

Collapse
 
aarone4 profile image
Aaron Reese

What about bank/national holidays?
A better solution to have a calendar table. This holds the date and a number of columns that are relevant to your particular requirements but typically
Day of week, day of month, day of year, week of year, month , quarter, financial month, financial quarter, is weekday, is weekend, is last day of month, is holiday USA, is holiday Canada is holiday Mexico

You can then use this to pick days in a range and just add up IsWeekday - IsHolidayUSA of your date range.

Collapse
 
boroscsaba profile image
Csaba Boros

Yes, you are right. Things can get more complicated. For my use-case I didn't have to worry about holidays, but I am thinking on writing a follow-up tutorial where I also account for holidays with a calendar table.