SSRS Expression for getting current week Sunday-Saturday - reporting-services

I am looking to make a report that gets the current week from sunday to saturday, i was thinking oh the headers of it having the date of the current week of running the report, does anyone know how to do that?

I assuming what you are asking is how to filter your dataset to show only records within the same week as the current week?
if so then you can do something like this
=WEEK(today()) = WEEK(Fields!myDateField.Value)
This will return True if the week is in the same week as the current week.
For more info on the WEEK function see here
https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008/aa337345(v=sql.100)

Related

SSRS Report Parameters Start date to be set for Friday when Current day is Monday

I have a report parameters start date and end date both set for previous day. I have report subscription that runs on each day of the week. But, when it executes on Monday, I need to change the Default parameter to run from the Prior Friday's date thru Sunday. How can I achieve this? TIA
I just replicated your use case locally.
For your start date parameter you will need expression as below. It will check if today is Friday (Weekday starts from Sunday) then set start date as Friday from last week else previous day. This shall work.
=IIF(WeekDay(today)=2,DateAdd("d",-3,today),DateAdd("d",-1,today))

Week To Date Based Off Current Date

I am looking for an expression that will allow to me find the date of Monday of the week of my Date Field, to be used in a filter for a tablix.
Example, my date field today is 22/01/2019. I would like an expression that will return 21/01/2019. If the date was 26/01/2019, it should still return 21/01/2019.
For next week 31/01/2019 would return 28/01/2019.
Week starting Monday going to Sunday.
If its also possible for a similiar expression but to find the beginning of the month as well?
Is that possible?
Many thanks
To get the date of last Monday that occurred you can use something like
=Today.AddDays(1-WeekDay(Today(),FirstDayOfWeek.Monday))
and for the first of the month its just
=DateSerial(Year(Today()), Month(Today()), 1)
Both the above are based on the today() function, if you need them based on a date parameter, then the expression is a little different but your question stated "today".
monday of the week use the following expression:
DateAdd("d",DatePart(DateInterval.WeekDay,Fields!myDatefield.Value,0,0)+1,Fields!myDatefield.Value)
first day of the month use the following expression:
=DateAdd("d",-(Day(Fields!myDatefield.Value)-1), Fields!myDatefield.Value)

SQL: Get row using dynamic date

First let me start by saying I am a Junior so I do apologise if this is a really stupid question or not possible.
I have a WHERE clause in an SQL script that gets rows if the date is later than a certain date. Like so:
WHERE
u.created > UNIX_TIMESTAMP('2018-04-01')
The month and day will always be the same but the year needs to be changed every year with the current year. So, next April I will have to make a change to the code to read:
WHERE
u.created > UNIX_TIMESTAMP('2019-04-01')
I was wondering if it's possible to make the year update to the current year IF the day and month are past 1st April
One option is to use DATE_FORMAT with the NOW() function as the source for the current year:
WHERE
u.created > UNIX_TIMESTAMP(DATE_FORMAT(NOW() ,'%Y-04-01'))
Demo

Current and Previous Month Revenue in Report

In Access 2013, I have a report showing revenue for each month of the year. I was success in getting a formula to name the previous month:
=Format$(DateAdd("m",-1,([ApptDate])),"mmmm",0,0)
What I am trying to get, is the revenue for the previous month for comparison, like a distribution chart. This is as close as I have gotten to something working, but the sum of the revenue for the previous month is too low (maybe only for a day's revenue?) Could anyone please help me put the following formula in the right order with right parameters to get the date needed?
=Sum(DateAdd("m",-1,([revenue])))
If I understood your problem correctly, you could use the DSum function by setting as criteria the month of the date to the previous month.
=DSum("[revenue]","YourTableName","Month([ApptDate])=" & Month(DateAdd("m",-1,Date())))

ssrs expression to calculate number of worked days in particular month

i need to calculate the number of worked days in a particular month. i have start date and end date depending on this i have to calculate the worked days in particular month. in ssrs report please help me with a ssrs expression to solve the problem.
i have a logic to do this but how to do it in a SSRS expression is a problem.
the logic is:
if(start date is in January than
start date-31/1/2014)
//this will give me the worked days in January
if(start date is not in January
start date-1/1/2014 //this gives me working days till January
(total working days)-( start date-1/1/2014)//this gives me working days after January 1
if((total working days)-( start date-1/1/2014)>31
then my answer is 31 days worked in January.
i have to convert this logic in to ssrs expression, is it possible?
is there any alternate way to do this ?
please help me with this.