looking to return the next Monday + 1 week from a date

Options
This discussion was created from comments split from: Formula to calculate the Monday after a date.

Answers

  • PeggyLang
    PeggyLang ✭✭✭✭✭
    Options

    I'm having trouble understanding this function.

    I am looking to return the next Monday + 1 week from a date.

    The above function is working, however, I don't quite understand it which probably means I would not be able to recreate it.

    What I think is happening in the above is

    if date =Sunday then return (date - (date-5))

    so if date is 07/24/22 then return would be 07/19/22?

    if date does not equate Sunday then return ((date-5)+11)

    so if date is 07/20/22 then return would be 07/26/22?

  • Sameer Karkhanis
    Sameer Karkhanis ✭✭✭✭✭✭
    Options

    The logic goes this way assuming your date is 7/24/2022:

    If the day of the week is Sunday (aka 1) then return Date - (day of the week - 5) which is 7/24/22 - (1-5) = 7/24/22+4 =7/28

    and if day is not Sunday then return Date - (day of the week -5) + 7 = 7/24/22 -(1-5) + 7 = 7/24/22 + 4 + 7 = 7/24 + 11 = 8/4/22

    In the above case the formula is giving to the next Thursday. If you want Monday then replace 5 with 2 (as Monday is 2nd day in the week)

    I also noticed that the formula fails if the date is Monday itself as it does not give next Monday. Here is the one with the fix,

    =IF(WEEKDAY(Date@row)=2, Date@row + 7, IF(WEEKDAY(Date@row)=1, Date@row - (WEEKDAY(Date@row)-2), Date@row-(WEEKDAY(Date@row)-2)+7))
    
    

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!