View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Stefi Stefi is offline
external usenet poster
 
Posts: 2,646
Default # of days in that month for a selected date

=DAY(DATE(YEAR(A1),MONTH(A1)+1,0))
seems to me a little bit simpler and doesn't require Analysis Toolpak
(EOMONTH does). You have to format the result cell as General in this case,
too.

Regards,
Stefi

€˛Valdus€¯ ezt Ć*rta:

As far as I know there is not a direct formula for this, however, by
combining several formulas it is possible to solve.

Let's say the "randomly selected date" is in cell A1, then put this formula
in A2 to display the number of days in that month:
=EOMONTH(A1;0)-DATE(YEAR(A1);MONTH(A1);1)+1

This is what happens:
EOMONTH(A1;0) returns the serial number of the last day in the moth of the
date in A1
YEAR(A1) returns the year of the date in A1
MONTH(A1) returns tha month of the date in A1
DATE(YEAR(A1);MONTH(A1);1) returns the date with same year as A1, same month
as A1, day 1 of that month
if you subtract the last day of the month with the first day of the month
and add 1 then you get the total number of days in that month

NOTE: Excel will most probably automatically change the Number format of
cell A2 to date-time in this case, which does not give you any useful output.
Select A2, choose format cells and change number to "General" (or to "Number"
with "decimal places" = 0)

"Narnimar" wrote:

What is the formula to return the # of days in that month for a randomly
selected date? Thanks for the help.