SSRS - weekday name - reporting-services

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.

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.

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.

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.

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))

Related

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)

Zabbix. How use function as of parameter another function

Idea use computed property to get difference between first day of month and current.
I use formula:
last("prtMarkerSuppliesLevel.1.2") - last("prtMarkerSuppliesLevel.1.2", dayofmonth("prtMarkerSuppliesLevel.1.2") )
first part work properly, but then i use dayofmonth i get error
Cannot evaluate expression: unexpected token at ")".
What is wrong?
Answer from zabbix forum thread link
Sorry, but you can not use last function in such way, it does not
support another last function as argument
the possible workaround - just create an item with scheduled interval
:
https://www.zabbix.com/documentation...stom_intervals
interval will be something like this: Code: md1h0m0 every 1st day of
each month at 0:00 This value will be collected only once a month and
will represent your prtMarkerSuppliesLevel at the begining of the
month.
then you can use last(your.current.item) - last(scheduled.item)
Regards, Kaspars

Netezza What is the best way to get the first day of the month for a date?

Select to_date(to_char(date_part('year',current_date),'0000') || trim(to_char(date_part('month',current_date),'00')) || '01','YYYYMMDD')
So far, this is the best I can come up with.
I am also unable to find a comprehensive language reference for Netezza SQL that has all functions in it, so please include a source in your answer.
Use date_trunc('month', current_ date), which is documented here.
Start with the date, for what I needed today, was using current date/month. Then find the last day of the current month. That's the outer shell for the first day as a systematic output:
start with the current date
use add_months (-1) to subtract a month;
find the last day of the previous month;
add 1 day.
I then decided to test out on February (leap year and normal), finding the first from the first, and then adding in finding the first of the next month. Also checked looking at a month ago from a month ending 31st and 30th. I think this should be flexible.
select current_date,
last_day(add_months(current_date,-1))+1 as firstdt_currmos,
last_day(current_date) as lastdt_currmos
;
select last_day(add_months('02-29-2016',-1))+1 as firstdt_febleap,
last_day(add_months('02-28-2019',-1))+1 as firstdt_febnorm,
last_day(add_months('07-01-2019',-1))+1 as firstdt_first,
last_day(add_months(current_date,-1))+1 as firstdt_currmos,
last_day(current_date)+1 as firstdt_nextmos,
last_day(add_months('07-31-2019',-1))+1 as firstdt_mos31st,
date(add_months('07-31-2019',-1)) as mosago_31st,
date(add_months('06-30-2019',-1)) as mosago_30th
;

Comparing todays date against first day of the week

I am trying to set a default parameter value in SSRS report. I want to test the current date to see if it equals the first day of the week (in my case Monday). If it is the first day of week, then I want the default value to be current date minus 2 days, if it is not the first day of the week then I want the default value to be current date minus 1 day.
I seem to have a syntax problem but it doesn't tell me where. My parameters are StartDate and EndDate.
this is what I've tried:
=iif(weekday(Today(),FirstDayOfWeek.Monday)==1,DateAdd("d",-2,today(),DateAdd("d",-1,today())
this is the generic error I get:
The value expression for the report parameter 'StartDate' contains eror:[BC30201] Expression expected.
Where am I going wrong?
You are trying to use Sql syntax in a SSRS VBA expression. SSRS VBA allows very similar expressions for date manipulation to Sql, the main difference being the use of the DateInterval enum.
So your expression needs to use VBA syntax:
=IIF(Weekday(Today, FirstDayOfWeek.Monday) = 1, DateAdd(DateInterval.Day, -2, Today), DateAdd(DateInterval.Day, , -1, Today))
It appears that you are missing a closing parentheses after the first logical part of the if statement and another to close the statement.
=iif(weekday(Today(),FirstDayOfWeek.Monday)==1,DateAdd("d",-2,today()),DateAdd("d",-1,today()))

How to get current month name in SSRS?

I need current month name as default perameter name in my ssrs report. How can I get current month name using an ssrs expression?
For example "27-09-2012" would become "September"
and one more i need....
27-09-2012 to previous month name as well (August)
First question:
=MonthName(Month(Fields!datefield.Value))
Second question:
=MonthName(Month(DateAdd("m", -1, Today())))
I think the second question answer might be something like that, first converting the date to month then subtracting 1 from the month value and then converting it to month name.
Further reading:
SSRS Reports get Month name from Month Index or from date
Converting month number to month name in reporting services
OFF: I would change the date format you are using to 2012-09-27 as it works in every setting and should give you peace of mind when converting date formats.
Don't subtract 1 b/c it won't work for January.
Use this:
MonthName(Month(DateAdd("m", -1, CDate(Today))))
As a note, I tried the suggestion of =MonthName(Month(today())). What I would get is #error for whatever field the expression was in. However, =MonthName(str(Month(today()))) worked for me. I am unsure of whether or not the MonthName method changed to require a string or if it is some issue with my program. Just figured I would post this in case anyone else was having the same issue.
For Previous Month i found universal way : =MonthName(Month(CDate(Today()))-1,False) for SEPTEMBER (Full Month Name) 'OR'
=MonthName(Month(CDate(Today()))-1,True) for SEP (Short Month Name)