Wednesday, April 11, 2012

SSRS get lat's sunday's date expression!

A recent question about how to get the last Sunday's date expression in SSRS.
so it's simply could be done using the SWITCH function in SSRS, the same concept could be used to get any date of the week's days.

=switch (
Weekday(today) = 1, today,
Weekday(today) = 2, dateadd("d", -1, today),
Weekday(today) = 3, dateadd("d", -2, today),
Weekday(today) = 4, dateadd("d", -3, today),
Weekday(today) = 5, dateadd("d", -4, today),
Weekday(today) = 6, dateadd("d", -5, today),
Weekday(today) = 7, dateadd("d", -6, today)
)
Hope that helps someone...

1 comment:

  1. Nice. MUCH more simple and straightforward than everything else I have seen so far today.

    ReplyDelete