How you calculate the difference for the weeknumber of a date and todays date, considering the year?

Options

I have a project schedule where we use

=IFERROR(WEEKNUMBER([End Date]@row) - WEEKNUMBER(TODAY()), "")

to calculate how far away the week number of the End Date is from the week number of Today's date. We have End Date's that are from Today's date just a year ago causing them to calculate a 0 as if the row item's End Date was this week. Is there anyway I can alter the formula to consider only this years End Date?

Tags:

Best Answers

  • Eric Law
    Eric Law ✭✭✭✭✭✭
    edited 03/23/23 Answer ✓
    Options

    @mwb

    Just add in an IF statement qualifying the year.

    =IF(YEAR([End Date]@row)=YEAR(TODAY()), (IFERROR(WEEKNUMBER([End Date]@row) - WEEKNUMBER(TODAY()), "")),"Wrong Year")


    EDIT:

    Just simplified it a bit

    =IFERROR(WEEKNUMBER([Due Date]@row) - WEEKNUMBER(TODAY()), "") + 52 * ((YEAR(TODAY()) - YEAR([Due Date]@row)))

    This will calculate regardless of the year. Hope this works better!

  • Eric Law
    Eric Law ✭✭✭✭✭✭
    Answer ✓
    Options

    @mwb I updated my solution to you, hope you see it, if not here is a better formula.

    =IFERROR(WEEKNUMBER([Due Date]@row) - WEEKNUMBER(TODAY()), "") + 52 * ((YEAR(TODAY()) - YEAR([Due Date]@row)))

Answers

  • Eric Law
    Eric Law ✭✭✭✭✭✭
    edited 03/23/23 Answer ✓
    Options

    @mwb

    Just add in an IF statement qualifying the year.

    =IF(YEAR([End Date]@row)=YEAR(TODAY()), (IFERROR(WEEKNUMBER([End Date]@row) - WEEKNUMBER(TODAY()), "")),"Wrong Year")


    EDIT:

    Just simplified it a bit

    =IFERROR(WEEKNUMBER([Due Date]@row) - WEEKNUMBER(TODAY()), "") + 52 * ((YEAR(TODAY()) - YEAR([Due Date]@row)))

    This will calculate regardless of the year. Hope this works better!

  • mwb
    mwb ✭✭
    Options

    @Eric Law

    That worked thank you!

  • Eric Law
    Eric Law ✭✭✭✭✭✭
    Answer ✓
    Options

    @mwb I updated my solution to you, hope you see it, if not here is a better formula.

    =IFERROR(WEEKNUMBER([Due Date]@row) - WEEKNUMBER(TODAY()), "") + 52 * ((YEAR(TODAY()) - YEAR([Due Date]@row)))

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!