Days remaining in month less Sundays.

S

Steve Romley

I need to automatically calculate the # of days remaining in the current
month, minus the total number of remaining Sundays. Any ideas??
 
J

JE McGimpsey

Steve Romley said:
I need to automatically calculate the # of days remaining in the current
month, minus the total number of remaining Sundays. Any ideas??

One way (assuming the date in A1):

This formula needs to be array-entered (CMD-RETURN):

=SUM(DATE(YEAR(A1),MONTH(A1)+1,0), -A1,-(WEEKDAY(A1-1 +
ROW(INDIRECT("1:"&(DATE(YEAR(A1),MONTH(A1)+1,0)-A1)+1)))=7))
 
J

JE McGimpsey

Oops - the previous one gives the wrong values for months ending on
weekends. Try (again, array-entered: CMD-RETURN):

=SUM(DATE(YEAR(A1), MONTH(A1) + 1, 0), -A1, --(WEEKDAY(A1)=1),
-(WEEKDAY(A1 - 1 + ROW(INDIRECT("1:" & (DATE(YEAR(A1), MONTH(A1) + 1,
0)-A1) + 1))) = 1))
 
S

Steve Romley

It works! Thanks


Oops - the previous one gives the wrong values for months ending on
weekends. Try (again, array-entered: CMD-RETURN):

=SUM(DATE(YEAR(A1), MONTH(A1) + 1, 0), -A1, --(WEEKDAY(A1)=1),
-(WEEKDAY(A1 - 1 + ROW(INDIRECT("1:" & (DATE(YEAR(A1), MONTH(A1) + 1,
0)-A1) + 1))) = 1))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top