Possible Duplicate:
TSQL Calculate week number of the month
This is my SQL Query
SELECT DATEPART(MONTH,PaymentDate) AS 'Month',
DATEPART(WEEK,PaymentDate) AS 'Week #',
SUM(COALESCE(Amount,0)) AS 'Amount',
SUM(COALESCE(Balance,0)) AS 'Balance'
FROM Payment
WHERE (MONTH(PaymentDate) = MONTH('2012-09-01'))
GROUP BY DATEPART(MONTH,PaymentDate),
DATEPART(WEEK,PaymentDate)
GO
I am try to get Total payment of a month in weekly fashion.
Now I have two Issues
1)As you can see it shows week # of the year not that month.
2)Also It show 6 weeks Groups not 4.
How can I Fix that.
Thanks.