total days in the month based on date

bark01

Board Regular
Joined
Sep 6, 2006
Messages
135
Office Version
  1. 365
Platform
  1. Windows
Hi, is there a formula that will say how many days there are in a month ?

B9 contains the a refrence to the first day of the month eg 1/7/2008 I want the cell above it (B8) to return 31. If the date reference is 1/6/2008 I want (B8) to return 30.

I'm using it to pro rata by the number of days in a month.

regards
 
One method I've used before is find the first day of the 'next' month and subtract a day.

Cell B1 "=DAY(DATE(YEAR(A1),MONTH(A1)+1,1)-1)"

HTH
Tony
 
Last edited:
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Isn't that a slightly less efficient version of the formula I posted?
=DAY(DATE(YEAR(B9),MONTH(B9)+1,0))

One method I've used before is find the first day of the 'next' month and subtract a day.

Cell B1 "=DAY(DATE(YEAR(A1),MONTH(A1)+1,1)-1)"

HTH
Tony
 
Upvote 0
moreover it's risky as was pointed out to me the other day by Peter_SSs... the 0 day approach is much safer.

EDIT: to quantify: using DAY in DATE function can be risky...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top