I am trying to retrieve the first and last date from a week and year in T-SQL. I found some exemples in stackoverflow or in google but nothing work well. The better exemple I find is this one :
DECLARE @WeekNo int= 20
DECLARE @Year int=2019
SELECT DATEADD(wk,@WeekNo-1,DATEADD(yy,@Year-1900,0)) AS WeekStart,
DATEADD(wk,@WeekNo,DATEADD(yy,@Year-1900,0))-1 AS WeekEnd
But I need the week start on a monday. And if I change it, it works for 2019 and not 2020. I am really stuck on this point.
Edit : First day of the week need to be monday. And week number are iso formated. First week of the year start only if 1 january is before a Friday (4 days in nexw year needed to be first week)