Forum Discussion

IF's avatar
IF
Post Prodigy
1 year ago
Solved

M language

Hi I am using the following and it is working well. How can I get dynamically: "today-3 years" and "today + end of next year". For example today is 2024-Oct-29.  today-4 years is 2020-Oct-29 toda...
  • SamWiseOwl's avatar
    1 year ago

    = Date.FromText( Text.From( Date.Year(Date.AddYears( Date.From(DateTime.LocalNow()),1))) & "-12-31")

  • Omid_Motamedise's avatar
    1 year ago

    You can add year to specific date by Date.AddYear and also calculate the last date of a year by Date. EndOfYear.

     

    So your dates can be achieved by the below formual.

     

    Today date => Date.from(DateRime.LocalNow())

    Date of next three year=> Date.AddYear(Date.from(DateRime.LocalNow()),3)

     

    End of next year => Date.EndOfYear(Date.AddYear(Date.From(DateTime.LocalNow()),1))