Hi have sql program that I run each week which includes this statement:
where cast(a.createddate as date) >= cast(‘2015-04-05’ as date) and cast(a.createddate as date) <= cast(‘2015-04-11’ as date)
What I would like to do is calculate the start and end dates automatically without any hardcoding of dates.
This program is run every Monday for the previous week which commences Sunday and ends Saturday
So if I was to run it on Monday 13 April my start date would be previous Sunday minus 1 week - ‘2015-04-05’ and my end date would be previous Saturday - ‘2015-04-11’
Much appreciated if anyone can help me with the syntax to achieve this.