In SSIS, how do I get the date for a specific day of the week? For example, how do I get last Sunday's date?
I assume I have to do some subtraction on the day-of-week, but not sure:
DATEADD("d", -DATEPART("DW", GETDATE()), GETDATE())
datessisssis-expressions
In SSIS, how do I get the date for a specific day of the week? For example, how do I get last Sunday's date?
I assume I have to do some subtraction on the day-of-week, but not sure:
DATEADD("d", -DATEPART("DW", GETDATE()), GETDATE())
Best Answer
You can use the following code to get the date for any given day in the current week:
I'm setting
@DesiredDay
to0
since you requested Sunday in your question. For Monday, set this to 1, for Tuesday set it to 2, etc.