I am trying to find the week of quarter from a cal_date_d table using sql. My table has cal_date, fiscal quarter start and end date. I also have a column which has the fiscal_week_of_year. and my fiscal year starts from feb.
However the closest query i've got to resolve this issue is below:
select datepart(week, DATEADD(MONTH,-10,cal_date)) - ((DatePart(quarter, DATEADD(MONTH,-10,cal_date))-1) *13),
Now the first week result i am always getting is 0. I am not sure where I am going wrong.
help me out on this one..
If you have
fiscal_quarter_start, then doesn't this work?
select 1 + datediff(day, fiscal_quarter_start, cal_date) / 7
This just calculates the number of days into the quarter and divides by 7.