How to find week number of a date
if start day is Tuesday and end day is Monday?
Here is the example criteria
Date Output
...... ..........
01-Dec-2014 (Monday) - 2014_DECEMBER_WEEK_NO_1
04-Dec-2014 (Thursday) - 2014_DECEMBER_WEEK_NO_1
29-Dec-2014 (Monday) - 2014_DECEMBER_WEEK_NO_4
30-Dec-2014 (Tuesday) - 2014_DECEMBER_WEEK_NO_5
31-Dec-2014 (Tuesday) - 2014_DECEMBER_WEEK_NO_5
I tried following query:
select CAST(UPPER(DATENAME(YEAR, @FROMDATE)) AS VARCHAR(20))
+'_'+CAST(UPPER(DATENAME(MONTH, @FROMDATE)) AS VARCHAR(20))
+'_WEEK_NO_'+CAST((DAY(@FROMDATE)
+ (DATEPART(DW, DATEADD (MONTH, DATEDIFF (MONTH, 0, @FROMDATE), 0))-1) -1)/7 + 1 AS VARCHAR(10))
This working fine if start day is Sunday and end day is Saturday.
Set your first day to
Tuesday
Execute the following query
UPDATE