• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Remaining off days in a month

dsudhakar

New Member
I want to calculate the remaining number of off days (say Sunday) from today in this month. Answer should be 3 as it is saturday 10 Nov 2012
 
Hi dsudhakar,


Welcome to Chandoo_Org.


Do you want to include 10 Nov 2012 or exclude in calculation? Following formula excludes 10 Nov 2012 but includes 30 Nov 2012 which is end date in this month.

In A1: put the date of your choice.

In any other cell place this formula:

=SUMPRODUCT(--(WEEKDAY(A1+ROW($A$1:INDEX(A:A,EOMONTH(A1,0)-A1)))={1}))

the formula can be extended for any day with minor tweak.
 
Hi Sudhakar ,


Try this :


=SUM(IF(WEEKDAY(ROW(INDIRECT(Start Date&":"&End Date)))=1,1,0))


which is to be entered as an array formula , using CTRL SHIFT ENTER.


Start Date is a reference to your cell which has the start date , say A1. End Date is a reference to the cell which has the end date , say A2.


Sunday has a day number of 1 , hence the check for equality to 1. If you want to check for the number of Saturdays , the number should be changed to 7 , as follows :


=SUM(IF(WEEKDAY(ROW(INDIRECT(Start Date&":"&End Date)))=7,1,0))


If you want the End Date always to be the end of the month , you can replace the End Date in the above formula , by the function EOMONTH(Start Date,0) ; to use this function , you will have to have the Analysis Toolpak add-in installed.


Narayan
 
Back
Top