I need an expression to get 5th last working day of the month.

 Is there any solution for this ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Seems like workday(date(ri!year, ri!month + 1, 01), -5) works when the first of the month after the one you're looking at is a work day.

    When it's not a work day, workday(date(ri!yearri!month + 1, 01), -4) seems to do the trick.  Something about it being counted when going backward or not counted.

    You have the calisworkday() to to see if first of the following month is a workday, using year, month + 1, 1, and probably for best results noon.

    so if(

    calisworkday("first of the following month"), 

    workday("first of the following month" minus 5),

    workday("first of the following month" minus 4)

    )

    Let me know how that goes

Reply
  • 0
    Certified Lead Developer

    Seems like workday(date(ri!year, ri!month + 1, 01), -5) works when the first of the month after the one you're looking at is a work day.

    When it's not a work day, workday(date(ri!yearri!month + 1, 01), -4) seems to do the trick.  Something about it being counted when going backward or not counted.

    You have the calisworkday() to to see if first of the following month is a workday, using year, month + 1, 1, and probably for best results noon.

    so if(

    calisworkday("first of the following month"), 

    workday("first of the following month" minus 5),

    workday("first of the following month" minus 4)

    )

    Let me know how that goes

Children
No Data