I’m using SQL SERVER 2005 and have a table which stores challans datewise. It has a field ‘Quantity’
I want to have a sum of Quantity for the weeks of the month. But these weeks have to start from Tuesday To Monday (this is an international standard for Oil Accounting)
I’m using SQL SERVER 2005 and have a table which stores challans datewise. It
Share
You can use set DATEFIRST to set the first day of the week, and then use datepart.
These SQL Statements should get you what you want. Assumption is that your table is called and the date column is
SET DATEFIRST 2;
select datepart(week, :my_date), sum(quantity)
from
group by datepart(week, :my_date)