View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ron Coderre Ron Coderre is offline
external usenet poster
 
Posts: 698
Default Count # of Days in a Month

With
A1: (any date)
B1: (a number from 1-7, inclusive)......1:Sun, 2:Mon.....7:Sat

This formula returns the count of the referenced day that are in the month
containing the date in A1

C1:
=SUM(INT(((WEEKDAY(DATE(YEAR(A1),MONTH(A1),1)-B1)+(DAY(DATE(YEAR(A1),MONTH(A1)+1,0))-1))/7)))

or....alternatively
C1:
=SUMPRODUCT(--(WEEKDAY(ROW(INDEX(A:A,DATE(YEAR(A1),MONTH(A1),1)) :INDEX(A:A,DATE(YEAR(A1),MONTH(A1)+1,0))))=B1))

If
A1 contains 5/15/2007
B1 contains 3 (Tue)
then the formula returns 5 (there are 5 Tuesdays in May 2007)

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"DF" wrote:

Does someone know off hand a function that would count the number of
individual days in a given month? For example, how many Mondays in
May 2007, how many Tuesdays, etc... I've searched the help files and
did not find anything I could use. Thanks in advance for your help.

--DFruge