Click here to Skip to main content
15,889,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
GetWeekEndHolidays(dtFromDate, dtToDate)

how to write function which gives you all holidays that fall on week ends between two dates
Posted
Comments
Sandeep Mewara 29-Jan-11 6:40am    
You have to write your own logic for it. No built in function as holidays would differ from place to place.
Sunasara Imdadhusen 29-Jan-11 6:57am    
Sandeep! You are right.
OriginalGriff 29-Jan-11 7:10am    
I don't know if you are aware of it, but there is now a "reply" feature for comments: move your mouse over the comment and it appears on the RHS. That way Sandeep would get a notification, rather than tanuja.

If you have Outlook installed on your machine, you can obtain the holidays list, which is shipped with its installation.

If you've installed Microsoft Office 2007, check the following path:
C:\Program Files\Microsoft Office\Office12\1033\Outlook.hol

This file contains known holidays for many countries in the following format:
...
[United States] 168
Christmas Day,2006/12/25
Christmas Day,2007/12/25
Christmas Day,2008/12/25
Christmas Day,2009/12/25
Christmas Day,2010/12/25
Christmas Day,2011/12/25
Christmas Day,2012/12/25
Christmas Eve,2006/12/24
...

It's just a thought :)

Regards
Espen Harlinn
 
Share this answer
 
Comments
Estys 29-Jan-11 10:40am    
and if he hasn't : http://www.e-webstyle.com/techinfo/index.php/ms-outlook/outlook-2003-holidays-for-2006-2012-outlookhol-download/
Espen Harlinn 29-Jan-11 10:41am    
Nice link, thanks :)
JF2015 29-Jan-11 11:59am    
Good idea. 5
Espen Harlinn 29-Jan-11 12:42pm    
Thanks JF2015!
#realJSOP 30-Jan-11 7:50am    
I wouldn't rely on outlook for *anything*...
Build a list of holidays:

0) Define the holidays indicates their ordinal date (day of the year).

1) Write a method that applies the ordinal date to the current year, and see if the day it lands on is either Saturday or Sunday. Store this boolean value (bool m_isWeekend) in the list item.

Compare the dates:

0) Compare the holiday dates with the specified date range, and check the m_isWeekend variable to see if it's a weekend holiday
 
Share this answer
 

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