Previous full week from Saturday to Friday - reporting-services

I need the previous full week in SSRS report builder , but the week is from Saturday to Friday. So the beginning of the working week is Saturday morning 00:01 AM and goes to Friday the following week at midnight.
DateFrom=DateAdd(DateInterval.Day, -6,DateAdd(DateInterval.Day, -2,DateAdd(DateInterval.Day, 1-Weekday(today),Today)))
DateTo=DateAdd(DateInterval.Day, -2,DateAdd(DateInterval.Day, 1-Weekday(today),Today))
I have these expressions which work for today, but if I advance the report servers time, it still has previous weeks dates.
I'm not 100% sure if that is the right way of testing this but the report I get has a date time stamp that says saturdays date
eg:
3/17/2018 2:59:20 PM

This seems to work , so happy Friday and thanks for the help!
From
=IIF(Weekday(Today)<7, DateAdd(DateInterval.Day, 0-WeekDay(Today, 1), DateAdd(DateInterval.Day, -7, Today)) , DateAdd(DateInterval.Day, -WeekDay(Today), Today))
To=IIF(Weekday(Today)<7, DateAdd(DateInterval.Day, -1-WeekDay(Today), Today), DateAdd(DateInterval.Day, 6-WeekDay(Today), DateAdd(DateInterval.Day, 0, Today)))

Related

Returning the date depending on today's weekday in SSRS

I am new to report building with SSRS.
I am currently trying to have an expression in SSRS show a specific date depending on wether today's day is on a weekend or not. This I tried to achieve by utilizing the different date functions Microsoft provides in their documentation. This is what I got so far:
=IIF(WeekdayName(weekday(DateAdd(DateInterval.Day, -1, today()))) = 'Monday', CDate(DateAdd("d", -3, Parameters!DateTo.Value)),
IIF(WeekdayName(weekday(DateAdd(DateInterval.Day, -1, today()))) = 'Sunday', CDate(DateAdd("d", -2, Parameters!DateTo.Value)),
CDate(DateAdd("d", -1, Parameters!DateTo.Value))))
As you can see I am trying to have it so if today's day is Sunday or Monday the date value returned should be the one from last Friday else it should return yesterday's date.
In Report Builder I'm receiving an error message stating that there is an expression expected and I cannot save the file.
What am I missing here? Is there maybe a different approach to achieving this? Thanks for any help.
BR,
Philipp
I would do it like this... There may be more efficient ways but this would be my approach...
=IIF(
Weekday(Today())=7 OR Weekday(Today())=1
,DATEADD(DateInterval.Day, (Weekday(Today())+1) * -1, Today())
, Today()
)
Note This assumes you week starts on a Sunday, if not adjust the first part of the IIF to suit.
So here we are saying...
If today is Saturday (7) or today is Sunday(1) then, subtract the (current day number +1) from the current date, else return the current date.

SSRS report #To parameters

I need last Sunday date with whole day time count. By using this
DateAdd(DateInterval.Day, -0,DateAdd(DateInterval.Day, 1-Weekday(today),Today)
I am getting time As 12AM, but I need all day time.

How to add time to last Sunday ssrs expression?

How to add the time 23:59:59 pm to the following expression:
=DateAdd(DateInterval.Day, 1-WeekDay(Today), Today)
I've tried adding the time
=DateAdd(DateInterval.Day, 1-WeekDay(Today)+ "23:59:59", Today)
The expression is returning me the last Sunday day but I need to add the time somehow
I think it's easier to subtract a second from tomorrow.
=TODAY.AddDays(1 - TODAY.DayOfWeek).AddSeconds(-1)
I think if you want to use DATEADD, you'd need one for each interval (Hour, minute and second).

MySQL first week of the year on WEEK function

I need some help. I want to get the week number of a specific date with the following system:
The week containing January 1st is the first week of the year. The week begins on Sunday. Range 1-53.
For example:
- Week 1 of 2015 begins on Sun 12/28/14 and ends on Sat 01/03/15.
- Week 1 of 2016 begins on Sun 12/27/15 and ends on Sat 01/02/15.
- Week 1 of 2017 begins on Sun 01/01/17 and ends on Sat 07/01/17.
I have read the WEEK(date[,mode]) function documentation, but none of these 'modes' match with my requirements.
How can I achieve this?
You can probably get this by using the DAYOFWEEK function. It will return you the value of what the day is (1-7 where 1 is Sunday, etc). From there, you can determine when the week has started and when it will end.
You have the WEEKOFYEAR as well. Please go thru manual
I was having the same problem, the function YEARWEEK solved it for me
SELECT YEARWEEK("2016-01-01");
>> 201552

SSRS - Report Builder 3.0 - This Day Last Year

I'm trying to get a Today vs This Day Last Year Comparison Report sorted.
I set a 'From' and 'To' date based on a 'Preset' parameter.
So if it is set to 'This Week' it sets the start date to Monday and the end date to Sunday.
What I want now is a Today vs This Day Last Year. So for example, if i were to do it for today, I would get 09/04/2015 vs 10/04/2014. So as today is Thursday, I want the nearest Thursday from 09/04/2014.
Also want the same for 'Yesterday'. So 08/04/2015 vs 09/04/2014
Is there a way to do this in either the Parameters SSRS expression, or within the custom 'Code' section?
To get this day last year, you can just subtract 52 weeks from today. Try this expression: =DateAdd("ww",-52,Today()). Likewise you can subtract 1 day from today to get yesterday: =DateAdd("d",-1,Today()).