I have a code that runs every weekday looking for the previous day, however on Mondays it looks from past Friday through Sunday. Right now, I am manually commenting in and out rows of code if it’s a Monday. How can I have it combined without having to touch it every Monday? I use placeholders to declare dates that will be used further down the code.
- /* If today is not MONDAY, then use lines 2&3; if today is MONDAY, use lines 4&5 */
- –DECLARE @STARTDATE DATE = getdate()-1
- –DECLARE @PREV15STARTDATE DATE = getdate()-15
- –DECLARE @STARTDATE DATE = getdate()-3
- –DECLARE @PREV15STARTDATE DATE = getdate()-17
Later on, I will have a select statement that uses the following:
where ACTIVITY_CREATE_DATE_TIME between @PREV15STARTDATE and @STARTDATE