Click here to Skip to main content
15,906,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone give me ideas on how to create and use holiday calendar tables.

I need to calculate South African school days, excluding weekends and holidays.
In my schoolterms table I have got columns StartDate and EndDate, I tried using DATEDIFF but it includes weekends and holidays.
Posted
Updated 4-Oct-11 10:12am
v3
Comments
André Kraak 4-Oct-11 16:12pm    
Edited question:
Removed unnecessary tags
Formatted text/code
Spelling/Grammar

1 solution

holiday table
NUMERIC ID
DATE HOLIDAY_DATE
VARCHAR COUNTRY

I get the feeling that's not enough for you, but you need specify your question.

Replay to the first comment to this solution

The algorithm:
List schoolDays = empty list

Loop over each date in your date range
  if(IsSchoolDay)
    Add current date to schoolDays

return schoolDays


IsSchoolDay is defined as
IsSchoolDay (Date date)

is date a saturday or sunday
  return false
is date in the holiday table
  return false

return true 
 
Share this answer
 
v3
Comments
SandraCy 4-Oct-11 16:04pm    
i need to calculate South african school days, excluding weekends and holidays. in my schoolterms table i've got columns StartDate and EndDate, i tried using DATEDIFF but it includes weekends.
Simon Bang Terkildsen 4-Oct-11 17:47pm    
See my response in the updated solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900