"Paul" <Pa**@discussio ns.microsoft.co mwrote in message
news:5D******** *************** ***********@mic rosoft.com...
Hi, I have a web application that I need to add 3 days to the Now day, but
need to make sure that I skip weekends and holidays. For example if Now
is
friday, 3 days + now should be tuesday, counting the current day as the
first
day. Now would never occur on a weekend or holiday. Anyhow just
wondering
if anyone has any ideas? Thanks.
It's a trivial matter to work out whether a DateTime variable relates to a
weekend or not by inspecting the DayOfWeek property:
http://msdn2.microsoft.com/en-us/lib...dayofweek.aspx
However, bear in mind that weekends are not always Saturday and Sunday
everywhere in the world.
As for public holidays, these differ from country to country. I'm not aware
of anything in the .NET Framework which will return whether given DateTime
and CultureInfo variables relate to a public holiday or not, although
Microsoft already know this information since it's possible to add public
holidays for individual countries to Outlook...
Therefore, what I do is hold a database table listing public holidays for
the next few years against a given country identifier. Armed with that, what
you require is easy enough by adding one day to any given DateTime variable
and incrementing a local variable by one if the resulting DateTime isn't a
weekend and doesn't appear in the database table of public holidays for the
country that you're working with. As soon as the local variable has a value
of 3, you have your result.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net