Search code examples
vbadateexpressionssrs-2008iif

Add 1 to current year in expression


I would like to learn how a year can be added to the current year in ELSE part of the following expression:

=IIF(Today() >= cDate("10/01/" + cStr(year(Today()))) AND Today() <= cDate("10/02/" + cStr(year(Today()))),
    cDate("11/01/" + cStr(year(FORMAT(Cdate(today), "MM-dd-yyyy")))),
        cDate("11/01/" + cStr(year(FORMAT(Cdate(today), "MM-dd-yyyy")))))

I tried to do this:

=IIF(Today() >= cDate("10/01/" + cStr(year(Today()))) AND Today() <= cDate("10/02/" + cStr(year(Today()))),
    cDate("11/01/" + cStr(year(FORMAT(Cdate(today), "MM-dd-yyyy")))),
        cDate("11/01/" + cStr(year(FORMAT(Cdate(today), "MM-dd-yyyy") + 1))))

But the report does not accept it as valid syntax.

Any help would be greatly appreciated.

Thank you.


Solution

  • You can use

    DateAdd("yyyy", 1, "10/1/2018")
    

    If you want you can formate the date

    DateAdd("yyyy", 1, Format("10/1/2018", "MM/dd/yyyy"))
    

    And you can format the result too!

    Format(DateAdd("yyyy", 1, Format("10/1/2018", "MM/dd/yyyy")), "MM/dd/yyyy")
    

    check it here https://www.techonthenet.com/excel/formulas/dateadd.php

    and here https://www.techonthenet.com/excel/formulas/format_date.php