number of calendar days, which is fine and then work out the number of
saturdays and sundays seperately but I think I'm only getting w

The SQL is:
UPDATE not_swcch
SET not_swcch.Calendardays =
DATEDIFF(day, [Entry Date], getdate()),
not_swcch.Saturdays =
DATEDIFF("ww", [Entry Date], getdate()),
not_swcch.Sundays =
DATEDIFF("ww", [Entry Date], getdate())
from not_swcch
How can I differentiate Saturday and Sunday?
ThankyouProbably the easiest and best solution to this problem is to use a
calendar table.
http://www.aspfaq.com/show.asp?id=2519
Stu|||try this.. you can check it and implement it in your update staement. Hope
this helps.
declare @.a datetime, @.b datetime
--you set the number of daysto subtract to test
set @.a = dateadd(dd,-102,getdate())
set @.b = dateadd(dd,3,getdate())
-- find out what date range you have set
select @.a as [start date],@.b as [end date],
datename(dw,@.a) as start_dow,datepart(dw,@.a) as start, datename(dw,@.b) as
end_dow,datepart(dw,@.b) as [end]
select datediff(ww,@.a,@.b) as [no of w

[no of days difference]
select datediff(ww,@.a,@.b) + case when datename(dw,@.a) = 'sunday' then 1 else
0 end as [no of sundays],
datediff(ww,@.a,@.b) + case when datename(dw,@.b) = 'saturday' then 1 else 0
end as [no of saturdays]
No comments:
Post a Comment