Calculate Days in a Month

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I need help finding a formula to calculate the number of days in a month
depending on the month you choose from a drop down menu.
Example:

In cell A1 user will be ask to select a month from a drop down menu.
In cell B1 I want the number of days in the month corresponding to the month
selected in A1. So, if February is chosen on A1, then 28 (days) would appear
on B1.

I was trying to do if statements, but I keep getting an error. Is there an
easy way to do this?

Thanks
LGG
 
Hi!
if February is chosen on A1, then 28 (days) would appear

What about leap years when Feb has 29 days?

One way:

In some location list the months:

J1 = January
J2 = February
J3 = March
...
J12 = December

=DAY(DATE(YEAR(TODAY()),MATCH(A1,J1:J12,0)+1,0))

Biff
 
Hello LGG

Well the easist way that I know to count the days in a month
=DAY(EOMONTH($A$1;0)) but as for the Leap Year I am not 100% sure.

I hope this is of help to you.


Paul Maynard
 
Hi

Add a sheet Months.
Months!A1="Month"
Months!A2=01.01.2006
(or any other 1st of month in any valid date format)
Months!A3=01.02.2006
Select the range Months!A2:A3, and format in some valid date format like
"mmmm yyyy" or "yyyy.mmmm".
Copy the range down for some reasonable amount of rows - you get a list of
months to be selected.

Select the list of months, and define it as a named range Months. Hide sheet
Months.

On your entry sheet, apply to some cell (p.e. B1) a data validation list
with Source=Months, and format the cell like month list on sheet Months.
Into another cell, enter the formula:
=IF($B$="","",DAY(DATE(YEAR($B$1),MONTH($B$1)+1,0)))
,or, with Analysis Toolpack Ad-In activated
=IF($B$="","",DAY(EOMONTH($B$1,0)))
 
Hi. I need help finding a formula to calculate the number of days in a month
depending on the month you choose from a drop down menu.
Example:

In cell A1 user will be ask to select a month from a drop down menu.
In cell B1 I want the number of days in the month corresponding to the month
selected in A1. So, if February is chosen on A1, then 28 (days) would appear
on B1.

I was trying to do if statements, but I keep getting an error. Is there an
easy way to do this?

Thanks
LGG

To check the days of the month, I assumed that

1. The month you are choosing is from a list of text strings, and not real
Excel dates formatted to show just the month.

2. The year is "this" year, so February will only show 29 days if "this" year
is a leap year.

B1:

=DAY((A1&YEAR(TODAY()))+32-DAY((A1&YEAR(TODAY()))+32))


--ron
 
Easy.... One line....
ASSUMING the value in A1 is a date


in B1:
=Date(year(a1),month(a1)+1,1))- Date(year(a1),month(a1),1))
 
Thanks Biff! This was really helpful. It works!!! You saved my work.
LGG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top