# Thread: Function for # of days in month (XL97)

1. ## Function for # of days in month (XL97)

Anyone have a function that will return the number of days in a month? I want to put a date in a cell (i.e. 01/01/2002) and then have a function in another cell that looks at that date and returns the number of days in that month.
Thanks

Dennis

2. ## Re: Function for # of days in month (XL97)

<img src=/S/hello.gif border=0 alt=hello width=25 height=29> Dennis

Try this for size: <font color=red> =DAY(DATE(YEAR(TODAY()),A1,0)) </font color=red>

In cell A1 type 2 you will get 31 for January
In cell A1 type 3 you will get 28 for February
In cell A1 type 4 you will get 31 for March

You see this formula gets the day of the serial number made up from today's year, wit the Month coming from a cell value A1 in this case, and the day set to zero which would mean the last day of the previous month, that is why you have to start with 2 ( I think <img src=/S/shy.gif border=0 alt=shy width=15 height=15> )

Play with it and make it work to suite your needs, and if you need any help just reply to this message.

Wassim <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

3. ## Re: Function for # of days in month (XL97)

Dennis

Try this one as well <font color=red> =DAY(DATE(YEAR(E1),MONTH(E1)+1,DAY(E1)-DAY(E1))) </font color=red>

This works with days as well.

HTH

Wassim <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

4. ## Re: Function for # of days in month (XL97)

If the date is in A1, then the following formula will give the number of days in the month.

<pre>=DAY(DATE(YEAR(A1),MONTH(A1)+1,0))
</pre>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•