I have below query where I have hardcoded date-2 and date-1
WHERE calendar_date between date-2 and date-1
group by 1
Is there any change where I can have dynamic date range?
if day is Monday then daterange should be last week monday to sunday.(Complete previous week)
if day is not monday then daterange should be monday to Previous day.(ie. for Friday it should give Monday to Thursday)
Please help me!
why do you post the same question twice?
What's your TD release?
WHERE calendar_date BETWEEN NEXT_DAY(CURRENT_DATE-8, 'mon') AND CURRENT_DATE-1
WHERE calendar_date BETWEEN TD_MONDAY(CURRENT_DATE-1) AND CURRENT_DATE-1