SSRS - weekday name
Asked Answered
A

4

6

any advice appreciated

I have as a column heading the expression =WeekdayName(weekday(fields!date.value))

This returns the day of the week, however, it is returning a day of the week one day in advance, eg when I put Monday's dates in the parameter it shows as 'Tuesday' in the report.

My question is can the above expression be tweaked to show the WeekdayName one day before, eg =WeekdayName(weekday(fields!date.value -1)) ? I tried this but got an error.

Thanks.

Ancestress answered 4/12, 2014 at 8:17 Comment(0)
T
7

So you want to subtract one day from the your incoming date then you can use the

  = DateAdd("d", -1, yourdateField)

This way you can subtract the any number of days from your date.

But did you try to see why it is giving the day of previous date. Do check the system date time or else check with the

 =WeekdayName(weekday(Today())) 

and see if it gives you the correct day of week for current date.

Trona answered 4/12, 2014 at 8:33 Comment(3)
Thanks for getting back. What I want to do is change where it says 'Tuesday' to 'Monday', etc, so the data in the report actually reports on the correct days. Eg at the moment when I run the report for 1/12/14 it says 'Tuesday' and I want to move this back a day. As to why it's giving the previous date in the first place I am mystified and will run a separate investigation. Thanks.Ancestress
You can go with DateAdd and -1 to reduce the day from your date so you can have your previous day.Trona
Yes this worked perfectly - =WeekdayName(weekday(dateadd("D",-1,fields!date.value))) - thanks for taking the trouble to get back to me.Ancestress
L
4

Weekday and weekdayname functions have both another optional argument for defining the starting day of the week. Problem is the 2 functions don' t default this argument to the same value so depending on your server settings you should explicitly set the second argument of these functions.

Lundin answered 23/6, 2015 at 12:13 Comment(0)
K
0

No need to invoke a date function. As the weekday() function returns and integer you can offset the result and use the Mod operator to keep it in bounds:

=WeekdayName((weekday(fields!date.value)+5) Mod 7)+1)

The parenthesis are important to ensure the addition comes first.

Kid answered 13/10, 2016 at 23:49 Comment(0)
I
0

Just for reference: OP asked again because of the weekday offset and this is the correct provided solution. =WeekdayName(weekday(Today())) gives me tomorrow

=WeekdayName(Weekday(Today(),FirstDayOfWeek.System))
Imperator answered 3/2, 2023 at 11:38 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.