I am stumbling with SQL …see if you can help with 5 and 6
Business Need
- I have myDate
- I want SQL to give me week number for myDate
- I want SQL to return week start date of this year for myDate
- I want SQL to return week end date of this year for myDate
- (Need help)I want SQL to return week start date of LAST YEAR for myDate
- (Need help)I want SQL to return week end date of LAST YEAR for myDate
Comments on Data
- Date provided
- Date falls in week 19 of 2014
- Sunday of week 19 of 2014
- Saturday of week 19 of 2014
- Sunday of week 19 of 2013 (Need help getting this date with SQL)
- Saturday of week 19 of 2013 (Need help getting this date with SQL)
Sample Data
- 5/6/2014
- 19
- 5/4/2014
- 5/10/2014
- 5/5/2013
- 5/11/2013
SQL Queseries
- NA
- SELECT datepart(week, '05/06/2014')
- SELECT CONVERT(varchar(50), (DATEADD(dd, @@DATEFIRST - DATEPART(dw, '05/06/2014') - 6, '05/06/2014')), 101)
- SELECT CONVERT(varchar(50), (DATEADD(dd, @@DATEFIRST - DATEPART(dw, '05/06/2014'), '05/06/2014')), 101)
- Man… I m hitting sql block here
- Again...hitting sql block here