View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
PCLIVE PCLIVE is offline
external usenet poster
 
Posts: 1,311
Default # of days in month

This works because of the DATE command. If you used this formula:
=DATE(2007,5,1)

The result is 5/1/2007.

If you used:
=DATE(2007,5,32)
Since you are using the DATE command and Excel knows that May 32nd, 2007 is
not a valid date, it moves to the next month and displays:
6/01/2007

The same thing applies if you use:
=DATE(2007,5,0)
Again, May 0,2007 is not a valid date...so Excel moves backward to the
previous month by one day, which will be the last day of the previous month
specified (in this case, 5 or May. So by adding 1 to the current month, we
get next month...and by finding day 0 of next month, we get the last day of
THIS month.

Hope this helps,
Paul


"dipsy" wrote in message
...
Thanks! It worked - I wanted to know how it works. I broke up the
formula
and get the parts. When I put it together -
DATE(YEAR(A1),MONTH(A1)+1,0) - I
get the date - 7/31/2001 and then day (7/31/2001) - 31. Why add 1 to the
month?

Thanks a ton!

"PCLIVE" wrote:

Where A1 contains a date:

=DAY(DATE(YEAR(A1),MONTH(A1)+1,0))


"dipsy" wrote in message
...
I know the month and want a formula that will tell me number of days in
the
month. For example, April would be 30 days and May would be 31 days.