Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 ssrs between function in expression

Author  Topic 

Anand.A
Posting Yak Master

109 Posts

Posted - 2012-03-03 : 06:08:24
hi

i create a reports in ssrs

in that report i want to get data

for more than 6 month and less than 1 year data

and 1 yr 10 2yr data

so i create a calculated field for this

but i want to write between function how to write between function in ssrs expression

i wrote expression for less than 12 month

how to write between expression

=iif(DateDiff("M",Fields!TIME_DATE.Value,Now()) > 12 ,Fields!AMOUNT.Value,NOTHING)

anand

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-03 : 09:37:46
Unlike T-SQL, there is no BETWEEN keyword in SSRS expressions, at least that I am aware of. But, you can always use the And operator to specify a date range - for example, this would pick the 24 months ago to 12 months ago:
=iif(DateDiff("M",Fields!TIME_DATE.Value,Now()) > 12  
And DateDiff("M",Fields!TIME_DATE.Value,Now()) <= 24
,Fields!AMOUNT.Value,NOTHING)
One thing to keep in mind is that when you do DATEDIFF("M" it is counting the number of month boundaries crossed. So DateDiff("M","1/31/2012","2/1/2012") (Jan 31 to Feb 1) would return 1, as would DateDiff("M","1/31/2012","2/29/2012")
Go to Top of Page
   

- Advertisement -