Last Day of Prior Month Formula

Linda_22165
Linda_22165 Altair Community Member
edited September 2022 in Community Q&A

I am trying to find a formula that would populate “last day of prior month”.   As an example, I would run a report on October 5, 2022, but would want to populate a column in the report with the last day of the prior month , September 30, 2022.  Do the experts have any advice?

Answers

  • Rebecca_Cronin
    Rebecca_Cronin
    Altair Employee
    edited September 2022

    Hi Linda, 

     

    You can utilize the following formula:

    lastday (DateAdjust (date,0,-1,0),"month")

    image

     

     

    In regards to the 'date' field/value you can utilize either 'a run report date' if that exists within the report and "extract" that as a field OR you can use the 'METADATA COLUMN' field FileCreated to then utilize that 'date' within the formula. 

     

    image

     

    HOPE THIS IS HELPFUL.

     

    Rebecca & DA Team

  • CPorthouse
    CPorthouse
    Altair Employee
    edited September 2022

    A couple of thoughts.  If you already have a date column and you want to find the last day of the previous month of that date column you could use the DateAdjust() function.  I would try this:

    dateadjust(date,0,0,-day(date))

    Where 'date' is my column that contains the date.  Make sure to include the minus (-) before the day function.

    image

    If you don't have a date column, you can use:

    lastday(dateadjust(today(),0,-1),"month")

  • Linda_22165
    Linda_22165 Altair Community Member
    edited September 2022

    Thank you all so much!  Very helpful!