? on Setting default value to Year of previous month

  • Hi,

    I know =Year(Today) will get me the current 4 digit year.

    What I need is the Year of the previous month.

    So if the report is run in January 2021, then the default value is 2020, if it is run in December of 2020, then its 2020

     

    Thanks

     

  • It's funny, when you see something in print, you get it....

    I came up with

    =Format(DateAdd(DateInterval.Month, -1, Today), "yyyy")

     

    And it works!!!

    Thanks

     

     

  • select year(eomonth(getdate(),-1))

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Thanks Steve, thats a bit more straightforward 🙂

  • In SSRS:

    =Year(Today.AddMonths(-1))

    =Today.AddMonths(-1).Year

     

     

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply