Days in Month Question

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

I am trying to create a formula that uses the number of days in a
month. For example, I put the date 07/31/2003 in cell "A1" and I want
to create a formula that will return the number of days in cell "A2"
It is important that I be able to enter any date in cell "A1" and have
the days value returned in cell "A2." I have tried multiple ways and
have had no luck. Any help out there would be appreciated.
 
Hi Joe

if i understand you correctly the following should work

=DAY(A1)

Cheers
JulieD
 
=VLOOKUP(MONTH(A1),daystable,2,FALSE)

and create a VLOOKUP table named DaysTable that contains 1-12 down one
column and the number of days in each month in the corresponding column just
to the right.........

Vaya con Dios,
Chuck, CABGx3
 
You want the number of days in the month--not the number of days into the month
for that date:

=day(date(year(a1),month(a1)+1,0))

The zeroeth day of a month is the last day of the previous month.
 
Dave:
any particular reason you enclosed
=date(year(a1),month(a1)+1,0) <<< which works!
inside of day() ?
TIA,
 
Hi JMay!

It depends what you want:

=DATE(YEAR(A1),MONTH(A1)+1,0)
Returns the date of the last day in the month
You could format that d or dd to get the number shown but the
underlying figure saved is a date serial number.

=DAY(DATE(YEAR(A1),MONTH(A1)+1,0))
Returns the number of days in the month.

If I wanted to apply $100 per day based on the number of days in the
month, I'd use the second option.

=DAY(DATE(YEAR(A1),MONTH(A1)+1,0))*100
Returns: 3100

If I used:
=DATE(YEAR(A1),MONTH(A1)+1,0)*100
Returns: 3807700



--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
JMay said:
Dave:
any particular reason you enclosed
=date(year(a1),month(a1)+1,0) <<< which works!
inside of day() ?
TIA,

Dave Peterson said:
You want the number of days in the month--not the number of days
into the
month
 
Clear as a bell!!
Thanks Norman,


Norman Harker said:
Hi JMay!

It depends what you want:

=DATE(YEAR(A1),MONTH(A1)+1,0)
Returns the date of the last day in the month
You could format that d or dd to get the number shown but the
underlying figure saved is a date serial number.

=DAY(DATE(YEAR(A1),MONTH(A1)+1,0))
Returns the number of days in the month.

If I wanted to apply $100 per day based on the number of days in the
month, I'd use the second option.

=DAY(DATE(YEAR(A1),MONTH(A1)+1,0))*100
Returns: 3100

If I used:
=DATE(YEAR(A1),MONTH(A1)+1,0)*100
Returns: 3807700



--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Hi JMay!

Never hesitate to ask for reasons! You'll get a lot more out of the
newsgroups that way.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 

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

Back
Top