January 6, 2012 at 12:44 am
Hello There
I need some help from the experts. I have a report requirement. My question is how to retrieve data from the table based on weekends i.e( sat and sun) in a specified month. I am using sql server 2000.
Thanks
January 6, 2012 at 2:41 am
Try using this in your query.
SELECT * FROM tablenae WHERE DATEPART(dw, datecolumn) IN (1, 7);
January 6, 2012 at 4:13 am
Thanks a lot. that worked.
I have another requirement where I want to retrieve data from the table after working hours (i.e)
Monday-Thursday : after 6pm and before 8am
and on weekends full day i.e from Friday 6pm to Monday -8am that includes Sat and Sunday)
Thanks once again.
January 6, 2012 at 4:24 am
You can answer that one yourself. Use the DATEPART function again. If you don't know the syntax, you'll find it in Books Online or on the web.
John
January 6, 2012 at 4:36 am
There's a very similar thread here.
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
January 8, 2012 at 6:42 pm
padhis (1/6/2012)
Try using this in your query.
SELECT * FROM tablenae WHERE DATEPART(dw, datecolumn) IN (1, 7);
Better make real sure what the DATEFIRST setting is if you're going to use that method. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply