March 31, 2008 at 9:13 pm
Hi friends,
I have a Order_date column where order dates are captured in SQL server 2005 DB, I need to find the order dates that falls on Week Days only for the last monthand show my report.
Select order_date ,product from Orders
where order_date between 03-01-2008 and 03-01-2008
and order_date ......(should be only Week Days)
Please help me in this Query,Thanks in Adv..!!!!
Claoker
March 31, 2008 at 9:22 pm
This link should help you.
March 31, 2008 at 10:56 pm
tickler_foryou (3/31/2008)
Hi friends,I have a Order_date column where order dates are captured in SQL server 2005 DB, I need to find the order dates that falls on Week Days only for the last monthand show my report.
Select order_date ,product from Orders
where order_date between 03-01-2008 and 03-01-2008
and order_date ......(should be only Week Days)
Please help me in this Query,Thanks in Adv..!!!!
Claoker
SET DATEFIRST 1 --Set first day of week = Monday
SELECT DATENAME(dw,SomeDate),*
FROM dbo.Orders
WHERE Order_Date >= DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0) --First of previous month
AND Order_Date < DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) --First of current month
AND DATEPART(dw,Order_Date) < 6
--Jeff Moden
Change is inevitable... Change for the better is not.
March 31, 2008 at 10:58 pm
p.s. A join to a Calendar table would be even more effective...
--Jeff Moden
Change is inevitable... Change for the better is not.
March 31, 2008 at 11:16 pm
Jeff Moden (3/31/2008)
p.s. A join to a Calendar table would be even more effective...
Jeff's link is excellent for your solution. You can also go thru this links:
http://codeinet.blogspot.com/2006/08/auxiliary-calendar-table-for-sql.html
http://codeinet.blogspot.com/2006/09/audit-table-data-changes-in-sql-server.html
🙂
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply