I need to have a formula to calculate the number of pay periods within a date range.
I have this code:
=SUM(IF((A1<=(IF(MOD(ROW(INDIRECT("1/1/2010"*1&":"&"12/31/2011"*1)),14)=13,ROW(INDIRECT("1/1/2010"*1&":"&"12/31/2011"*1)),0)))*(A2>=(IF(MOD(ROW(INDIRECT("1/1/2010"*1&":"&"12/31/2011"*1)),14)=13,ROW(INDIRECT("1/1/2010"*1&":"&"12/31/2011"*1))))),1,0))
The cells A1 & A2 have 03/07/2011 and 12/31/2011 respectively in them.
and it returns 22, which has been correct.
However, the definition of what a "pay period" is has been amended. In addition to it being a Friday (which is why the formula starts on 1/1/2010), it now must be at least a two week period also, which would make the new, correct answer 21.
Is there a way to modify the above formula to make that determination that there are 21 2 week periods between 3/7 & 12/31, and not 22?
Thanks!
I have this code:
=SUM(IF((A1<=(IF(MOD(ROW(INDIRECT("1/1/2010"*1&":"&"12/31/2011"*1)),14)=13,ROW(INDIRECT("1/1/2010"*1&":"&"12/31/2011"*1)),0)))*(A2>=(IF(MOD(ROW(INDIRECT("1/1/2010"*1&":"&"12/31/2011"*1)),14)=13,ROW(INDIRECT("1/1/2010"*1&":"&"12/31/2011"*1))))),1,0))
The cells A1 & A2 have 03/07/2011 and 12/31/2011 respectively in them.
and it returns 22, which has been correct.
However, the definition of what a "pay period" is has been amended. In addition to it being a Friday (which is why the formula starts on 1/1/2010), it now must be at least a two week period also, which would make the new, correct answer 21.
Is there a way to modify the above formula to make that determination that there are 21 2 week periods between 3/7 & 12/31, and not 22?
Thanks!