Posted: 5/17/2012
hi
i need to have expression in textbox like
= "value on " + dateadd("dd" , - 1 , dateadd("yy",datediff("yy",0,filed1.value),0))
but when i run report it shows like #error
-----------------
another question is how to add filed value as sum
example.
item1 1000
item2 2000
total 3000
i need to have sum of this field in total.
how to add this values in ssrs
dateadd(DD, -1, dateadd(YY,datediff(yy,0,@date),0))
1. datediff("yy",0,filed1.value) is not correct
instead of "yy" has be "yyyy", instead of 0 has be date value
thanks alot ,its working now
can you write ,how this should be exactly.
i dont what should i put in place of dd,still getting error
Instead of DD or YY use DateInterval.Day and "yyyy"
and 0 is not a valid date format, so use you @date parameter or Fields!filed1.Value(date value)
=dateadd(DateInterval.Day, -1, dateadd("yyyy",datediff("yyyy",Fields!filed1.value,@date),@date))
i cannot use anything else in plac eof 0,
the value will be different
= "Portfolio value on " + dateadd(DateInterval.Day, -1, dateadd(DateInterval.Year,datediff(DateInterval.Year,0,Fields!ThruDate.Value),0))
this is my complete expression , how can i place anything else in place of 0
Syntax
DATEDIFF(interval, datetime, datetime)
you can't use 0 for datetime parameter
interval
Specifies the units (year, quarter, month, day, hour, minute, second or week) used to calculate the date difference.
datetime
Specifies the start date.
Specifies the end date.
http://msdn.microsoft.com/en-us/library/aa337092%28v=sql.90%29.aspx
Posted: 5/18/2012
I am not sure the 0 is your problem. In T-SQL a 0 converts to 1900-01-01 00.00.00.000. So if it is the zero that is really causing the problem you should be able to substitute 1900-01-01 00.00.00.000 but since you only need the date you should be able to just use 1900-01-01.
Rather than saying it doesn't work, why don't you try to tell us what you are trying to do with the expression?
ok.what i am trying to do is ,
i hv 1 textbox, which should show value like "value on (date)
this date should be last day of previous year
and this is calculting based on param @todate
so if @todate = 03/31/2010
the report should show value on 12/31/2009
this exp works on sql,dont know y its not working in ssrs
SSRS doesn't like the zero, so you need to substitute a hard date for it. This should work for you
=DATEADD("d",-1,DATEADD("yyyy",DATEDIFF("yyyy","1/1/1900",@Date),"1/1/1900"))
thanks daniel.
it works
Please mark the question as answered