Reputation: 11
I am getting error while using the following code in Date Parameter Expression
dateadd("m",datediff("m",0,today())-1,0)
Upvotes: 1
Views: 10423
Reputation: 39566
Your expression looks like an adaptation of a common T-SQL pattern to get the first day of the month - in your case it looks like it's based off yesterday's date?
You can't just convert this to an SSRS expression with minimal changes, you have to leverage the standard SSRS functions. This works for me:
=DateSerial(Year(DateAdd(DateInterval.Day, -1, Today()))
, Month(DateAdd(DateInterval.Day, -1, Today()))
, 1)
Here we get yesterday's date using DateAdd(DateInterval.Day, -1, Today())
, and then use DateSerial
to construct the start of the month by using Year
and Month
based on the above expression, then using 1 (i.e. the first of the month) as the day part.
Upvotes: 1