Hi,
I need weeked dates(Friday, satday and sunday) query in ms sql server, means i need to display only those days events, when i select weeked option in my page
Pls help to me
I need Weeked dates Query in Sql server 2005
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 21, 2012, 7:49 PM EDT
you can find weekend days by using DATEPART function in SQL for given date.
select DATEADD(dd, 6-(DATEPART(dw, getdate())), getdate()) -- Friday
select DATEADD(dd, 7-(DATEPART(dw, getdate())), getdate()) -- sat
select DATEADD(dd, 8-(DATEPART(dw, getdate())), getdate()) -- sun
but what is your requirment?
above is work only for given date.
hope this will help you.
hj jh81 reputationPosted Aug 21, 2012, 1:43 AM EDT
declare @d datetime
select @d = '20120101' --'20090101' if you want 2009 etc etc
select dateadd(dd,number,@d) from master..spt_values
where type = 'p'
and year(dateadd(dd,number,@d))=year(@d)
and
(DATEPART(dw,dateadd(dd,number,@d)) in (1,6,7))
Please mark as answer if your problem is solved else let me know the problem
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Aug 21, 2012, 6:30 PM EDT