Thanks:  0
Likes:  0

Thread: Count Days in a Month

1. Count Days in a Month

Dear all

Could someone explain below formula to me please.
Code:
`=DAY(DATE(YEAR(A1),MONTH(A1)+1,1)-1)`
The red parts, no idea.

Thank you very much

2. Re: Count Days in a Month

Originally Posted by Vanda_a
Dear all

Could someone explain below formula to me please.
Code:
`=DAY(DATE(YEAR(A1),MONTH(A1)+1,1)-1)`
The red parts, no idea.

Thank you very much
1. Given a date, the formula constructs first a first day date following the month/year of A1.

A1 = 4/20/2015

==> 5/1/2015

Note that this is DATE applied to 2015, 5 (MONTH of A1, which is 4, plus 1) and 1.

2. Subtracting 1 from the first day date of (1), that is,

5/1/2015 minus 1, we get:

==> 4/30/2015

3) DAY applied to (2), we get:

==> 30

which is days April (of 2015) counts.

3. Re: Count Days in a Month

1. Given a date, the formula constructs first a first day date following the month/year of A1.

A1 = 4/20/2015

==> 5/1/2015

Note that this is DATE applied to 2015, 5 (MONTH of A1, which is 4, plus 1) and 1.

2. Subtracting 1 from the first day date of (1), that is,

5/1/2015 minus 1, we get:

==> 4/30/2015

3) DAY applied to (2), we get:

==> 30

which is days April (of 2015) counts.
Understand it now. Thank you very much.

4. Re: Count Days in a Month

Vanda_a, Good morning.

I suggest you to use this formula:

=DAY(EOMONTH(A1),0)

I think it's more simple.

I hope it helps.
Have a nice day.

5. Re: Count Days in a Month

Originally Posted by Vanda_a
Understand it now. Thank you very much.
You are welcome.

Since EOMONTH is directly available in the recent Excel versions...

=DAY(EOMONTH(A1,0))

can also be invoked to the same effect.

6. Re: Count Days in a Month

Alternative to last day of previous month from today:

=DAY(TODAY()-DAY(TODAY()))

or a date in A1

=DAY(A1-DAY(A1))

7. Re: Count Days in a Month

You are welcome.

Since EOMONTH is directly available in the recent Excel versions...

=DAY(EOMONTH(A1,0))

can also be invoked to the same effect.
Yeah... This one is alot easier.

Thanks again

8. Re: Count Days in a Month

Originally Posted by Marcílio_Lobão
Vanda_a, Good morning.

I suggest you to use this formula:

=DAY(EOMONTH(A1),0)

I think it's more simple.

I hope it helps.
Have a nice day.
Thanks

9. Re: Count Days in a Month

Originally Posted by snb_
Alternative to last day of previous month from today:

=DAY(TODAY()-DAY(TODAY()))

or a date in A1

=DAY(A1-DAY(A1))
Thanks

User Tag List

Posting Permissions

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