local datetimevar target;
if DATEPART(dw,'6/5/11') <> 1
target := DATEADD("YY,"-1,'6/5/11') + DATEPART("dw",'6/5/11') - DATEPART("dw",dateadd(yy,-1,'6/5/11'))
else
target := DATEADD("YY",-1,'6/5/11') + DATEPART("dw",'6/5/11') - DATEPART("dw",dateadd(yy,-1,'6/5/11'))+7
this worked for me in sql server...
it finds out the date from a year ago and then adjusts it for the day of week to get the same day of week.
Edited by lockwelle - 02 Jun 2011 at 4:11am