
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!http://www.aspfaq.com/2519
http://www.aspfaq.com/
(Reverse address to reply.)
"skb" <nospamskberen@.msn.com> wrote in message
news:ezJye1qGFHA.3068@.tk2msftngp13.phx.gbl...
> How do I calculate the number of w

>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!|||I dont think there is a direct function to do this.. but here is a way
around....(Please excause any syntex errors.. I am just writing off
the top of my head..)
-- ****************************************
****************
Declare @.startdate smalldatetime,
@.enddate smalldatetime,
@.tempdate datetime,
@.holiday smallint
set @.startdate = '01/01/2005' -- set to relevent start date
set @.enddate = '01/31/2005' -- set to relevent end date
set @.holiday = 0
Set @.tempdate = @.startdate
while @.tempdate <= @.enddate
begin
print convert(varchar, @.tempdate) + ' : ' + DateName (dw, @.tempdate )
if DateName (dw, @.tempdate ) = 'Saturday'
begin
print @.holiday
set @.holiday = @.holiday + 1
end
if DateName (dw, @.tempdate ) = 'sunday'
begin
print @.holiday
set @.holiday = @.holiday + 1
end
set @.tempdate = dateadd(d,1,@.tempdate)
end
select 'Total number of holidays between ' + convert (Varchar,
@.startdate) + ' to ' + convert (Varchar, @.enddate) + ' : ' + convert
(varchar, @.holiday)
-- ****************************************
****************|||If you only need w

columns to show whatever your business needs in the way of temporal
information. Do not try to calculate holidays in SQL -- Easter alone
requires too much math.
CREATE TABLE Calendar
(cal_date DATE NOT NULL PRIMARY KEY,
fiscal_year SMALLINT NOT NULL,
fiscal_month SMALLINT NOT NULL,
w

holiday SMALLINT NOT NULL
CHECK(holiday IN (0,1)),
day_in_year SMALLINT NOT NULL,
..);
A calendar table for US Secular holidays can be built from the data at
this website, so you will get the three-day w

http://www.smart.net/~mmontes/ushols.html|||Thanks for the help...For performance I think creating a table with
w

*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
No comments:
Post a Comment