title: Week of quarter calculation SQL
body: <p>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:</p>
  
  <pre><code>select datepart(week, DATEADD(MONTH,-10,cal_date)) - ((DatePart(quarter, DATEADD(MONTH,-10,cal_date))-1) *13), 
         fiscal_week_of_year,
         weekofqtr,
         cal_date
    from cal_date_d_tst 
  </code></pre>
  
  <p>Now the first week result i am always getting is 0. I am not sure where I am going wrong.</p>
  
  <p>help me out on this one..</p>
  
  <p><a href="https://i.stack.imgur.com/shYXm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/shYXm.png" alt="Description"></a> </p>