title: Get week period based on week number, month and year sql
body: <p>I need to get the first day and the last day of the week based on the number of the week, year and month</p>
  <p>My week starts on saturday and finish in friday
  Example:
  Year: 2020
  Week: 45</p>
  <blockquote>
  <p>Normal period of week: First day: 2020-10-31 ~ Last day: 2020-11-06</p>
  </blockquote>
  <p>I need return something like</p>
  <blockquote>
  <p>October: First day: 2020-10-31 ~ last day: 2020-10-31</p>
  <p>November: First day 2020-11-01 ~ last day: 2020-11-06</p>
  </blockquote>
  <p>my query to return last day of week:</p>
  <pre><code>select DATEADD (WEEK, @PcpSemana, DATEADD (YEAR,  ('20' + LEFT(@PcpPeriodo,2))-1900, 0)) - 5 as lastDayOfWeek 
  </code></pre>
  <p>my query to return first day of week</p>
  <pre><code>SELECT WeekStart = DATEADD(DAY, 
                          (CEILING(DATEPART(DAY, DATEADD (WEEK, @PcpSemana, DATEADD (YEAR,  ('20' + LEFT(@PcpPeriodo,2))-1900, 0)) - 5) / 7.0) - 1) * 7,
                          DATEADD(MONTH, DATEDIFF(MONTH, 0,DATEADD (WEEK, @PcpSemana, DATEADD (YEAR,  ('20' + LEFT(@PcpPeriodo,2))-1900, 0)) - 5), 0));
  </code></pre>
  <p>I'm using SET DATEFIRST 6<br />
  I can't evolve much</p>
  <p>PcpPeriodo contains YYMM ( 2011) = 2020 / 11 )
  PcpSemana contains weeknumber (45) (01 ~ 53)</p>