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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Aug 21, 2012, 11:49 PM
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.
Akkiraju IvaturiPosted Aug 21, 2012, 10:30 PM
hj jhPosted Aug 21, 2012, 5:43 AM
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