[Help] How to generate working dates of a year?

lok1234

Registered User.
Local time
Today, 15:39
Joined
Nov 26, 2008
Messages
22
Dear all,

1. Assume TableA stores the holiday dates (exclude Saturday and Sunday) of a year,

HDays Year
----- -----
01-01-2009 2009
10-04-2009 2009
13-04-2009 2009

...etc


2.) Right now, I have to insert record to TableB so that it will contains the working dates of 2009. The holiday dates can be found from TableA and these dates should be excluded in TableB. Besides, TableB should exclude the dates of Saturday and Sunday.

How to write a query for that case? (similar to that:)

insert into tableb(workdate, year)
select .... from TableA...

Many thanks
 
What I would do is create a table that holds the following details

TodaysDate - Day of the year
IsWeekEnd - Is this day a sat or sun
IsHoliday - Is this day a known holiday

Then I would populate the table with ALL the days of the year and flag the other fields accordingly

That way you can manage your code easier

David
 

Users who are viewing this thread

Back
Top Bottom