How you calculate the difference for the weeknumber of a date and todays date, considering the year?
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?
Best Answers
-
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 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
-
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!
-
That worked thank you!
-
@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
Categories
Check out the Formula Handbook template!