# 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:

• ✭✭✭✭✭✭
Options

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!

• ✭✭✭✭✭✭
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)))

• ✭✭✭✭✭✭
Options

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!

• ✭✭
Options

That worked thank you!

• ✭✭✭✭✭✭