View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Marek Marek is offline
external usenet poster
 
Posts: 7
Default Days in a month Function

that works a treat - many thanks for that. It never ceases to amaze me the
input on these forums and the speed folk can respond nowadays.


"George Nicholson" wrote:

In VB, the last day of any month is day 0 of the following month (i.e.,
First of next month, less one day)

NumDaysInMyDate = Day(DateSerial(Year(MyDate), Month(MyDate)+1, 0))

The DateSerial(year,month,day) function calculates "Day 0" of the month
following MyDate. Equivalent to MyDate's EOM.
The Day(datevalue) function returns the number (1-31) of that day (i.e., the
number of days within the month of MyDate)

Leap years are covered.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"Marek" wrote in message
...
Hi,

Does anyone know how to work out how many days a month has? Something
that
can accomodate leap years as well. So, if it's Feb 2005 it's 28 days. If
it
were Feb 2004 it would be 29 days.


--
Many thanks in advance for any assistance