I need the last week Monday and Sunday , say today is March 18th hence the SSRS expression should return March 10th -Monday March 16th -Sunday
I was able to get it using SQL
select dateadd(d,(2-datepart(dw, getdate())), dateadd(ww,-1,getdate())) select dateadd(d,(1-datepart(dw, getdate())), getdate())
not sure how to get it done via SSRS expression
Given that the report can be executed at any day and time within the week and it should automatically pick up Monday's and Sunday's date. Any help will be greatly appreciated in giving me a help in writing correct SSRS expression for above If everything seems to be going well, you have obviously overlooked something.
Date Time Functions of SSRS: Today () - Returns or sets a Date value containing the current date according to your system: Now () - Returns or sets a Date value containing the current date according to your system. MonthName - Returns a String value containing the name of the specified month.
Given that the report can be executed at any day and time within the week and it should automatically pick up Monday's and Sunday's date. Any help will be greatly appreciated in giving me a help in writing correct SSRS expression for above
To add/substract date or time (day, month, year, sec etc.) with given date field we can use DateADD function in SSRS expression, which returns a Date value containing a date and time value to which a specified time interval has been added: DateDiff - function returns a Long value specifying the number of time intervals between two Date values.
SSRS VBA allows very similar expressions for date manipulation to Sql, the main difference being the use of the DateInterval enum. Without checking your expressions, it will convert to SSRS VBA as follows:
Last Monday:
=DateAdd(DateInterval.Day, 2-WeekDay(Today), DateAdd(DateInterval.Day, -7, Today()))
Last Sunday:
=DateAdd(DateInterval.Day, 1-WeekDay(Today), Today())
To get Sunday from Last Week : (Note: Last Week Sunday is different from Last Sunday).
=DateAdd(DateInterval.Day, 1-WeekDay(Today), DateAdd(DateInterval.Day, -7, Today))
To get Saturday from Last Week :
=DateAdd(DateInterval.Day, 7-WeekDay(Today), DateAdd(DateInterval.Day, -7, Today))
with Weekdays values as below:
1 - Sunday
2 - Monday
3 - Tuesday
4 - Wednesday
5 - Thursday
6 - Friday
7 - Saturday
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With