ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Calculate Number of Days in a Month (https://www.excelbanter.com/excel-worksheet-functions/166958-calculate-number-days-month.html)

Gary T

Calculate Number of Days in a Month
 
Hi

I want to be able to use a formula to calculate the number of days in a
month based on a date in question - e.g.

in A1 I enter a date (e.g. 21 November 2007)

in A2 I want to put a formula that will tell me, based on what I have
entered into A1, how many days that month has (e.g. based on what I put in A1
- 21 November 2007, the formula would return 30).

I also need this to account for leap years.

Regards

Mike H

Calculate Number of Days in a Month
 
Maybe:-

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

Mike

"Gary T" wrote:

Hi

I want to be able to use a formula to calculate the number of days in a
month based on a date in question - e.g.

in A1 I enter a date (e.g. 21 November 2007)

in A2 I want to put a formula that will tell me, based on what I have
entered into A1, how many days that month has (e.g. based on what I put in A1
- 21 November 2007, the formula would return 30).

I also need this to account for leap years.

Regards


Dave Peterson

Calculate Number of Days in a Month
 
Or just:
=DAY(DATE(YEAR(A1),MONTH(A1)+1,0))

The zeroth day of the month is the last day of the previous month.

Mike H wrote:

Maybe:-

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

Mike

"Gary T" wrote:

Hi

I want to be able to use a formula to calculate the number of days in a
month based on a date in question - e.g.

in A1 I enter a date (e.g. 21 November 2007)

in A2 I want to put a formula that will tell me, based on what I have
entered into A1, how many days that month has (e.g. based on what I put in A1
- 21 November 2007, the formula would return 30).

I also need this to account for leap years.

Regards


--

Dave Peterson

Teethless mama

Calculate Number of Days in a Month
 
=DAY(EOMONTH(A1,0))

Required ATP add-ins


"Gary T" wrote:

Hi

I want to be able to use a formula to calculate the number of days in a
month based on a date in question - e.g.

in A1 I enter a date (e.g. 21 November 2007)

in A2 I want to put a formula that will tell me, based on what I have
entered into A1, how many days that month has (e.g. based on what I put in A1
- 21 November 2007, the formula would return 30).

I also need this to account for leap years.

Regards



All times are GMT +1. The time now is 10:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com