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
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 65.9K Get Help
- 429 Global Discussions
- 147 Industry Talk
- 486 Announcements
- 5.2K Ideas & Feature Requests
- 86 Brandfolder
- 151 Just for fun
- 74 Community Job Board
- 498 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 305 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!