Forum Discussion

CourtneyLaw's avatar
CourtneyLaw
Qrew Member
3 years ago

Formula Help Needed - Round a date to a specific day of the week

I am looking for a way to round a date field to a specific day of the week. I.e., my date falls on a Monday or a Friday, but I want the date field to show the upcoming Wednesday date. Any solutions?

------------------------------
Courtney Law
------------------------------
  • Is this the mapping you want?
    Monday -> Wednesday
    Tuesday -> Wednesday
    Wednesday -> Wednesday
    Thursday, Friday, Saturday, Sunday  -> the next Wednesday

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------
    • CourtneyLaw's avatar
      CourtneyLaw
      Qrew Member
      Correct!

      ------------------------------
      Courtney Law
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        OK, try this

        var number DaysToAdd = Case(DayOfWeek([My Date Field]),
        1,2,
        2,1,
        3,0,
        4,6,
        5,5,
        6,4,
        0,3);

        [My Date Field] + Days($DaysToAdd)

        ------------------------------
        Mark Shnier (YQC)
        mark.shnier@gmail.com
        ------------------------------