Search code examples
sql-serverreporting-servicesssrs-2008bidsssrs-expression

SSRS BIDS expression language Month Part from Current date


In BIDS I need an expression to take the YEAR part of a date which is minus 1 month of the current date.

For example Today's date is 20/04/2012 the desired expression would return:

2012

If todays date was 05/01/2012 the desured expression would return:

2011


Solution

  • so the rule is:

    • If it's January -> return last year
    • else -> return this year

    Right?

    =IIf(Datepart("m", Fields!date.Value)=1,Datepart("YYYY", Fields!date.Value)-1,Datepart("YYYY", Fields!date.Value))