I have in the 6th row 12 column with the months of a year but it's an abbreviation; ex: Jan, Feb, Apr..., Dec. I want to count the days of the month in the cell just above it (7th row).
the abbreviation is a problem.
Thank you for your help.
I have in the 6th row 12 column with the months of a year but it's an abbreviation; ex: Jan, Feb, Apr..., Dec. I want to count the days of the month in the cell just above it (7th row).
the abbreviation is a problem.
Thank you for your help.
Because the number of days per month changes depending on the year (since some years are leap years), I would recommend having years attached to your month. For example, write January 2023 instead of January. You can change how the cell displays the date afterwards by right-clicking your month cell, and then clicking "Format Cells".
To count the number of days in the month, you can just find the day number of the last day of the month (or, as the code below does, takes the first day of the next month and subtracts 1).
=DAY(DATE(YEAR(A1), MONTH(A1) + 1, 1) - 1)
Many ways to do it, here are few alternatives, that would work with MS365 & earlier versions as well, assumption is taken that the default year is 2023
, using EOMONTH( ) & DAY( ) functions.
• Formula used in cell B7
=DAY(EOMONTH(B6&" 1, "&2023,0))
• Formula used in cell B8
=DAY(EOMONTH(DATE(2023,MONTH(B6&1),1),0))
• Formula used in cell B9
=DAY(EOMONTH(B6:M6&" 1, "&2023,0))
Note: The first two formulas where you need to drag right while the last one, will spill right, so no need to drag. Also instead of hardcoding the year, you can use cell reference to make it dynamic, like as below.
Here is two alternatives as suggested by P.b
=DAY(DATE(2023,COLUMN(B1:M1),1)-1)
=DAY(EOMONTH(1&B6:M6&2023,0))
Caveat: Few alternatives depend on the Locale Date Settings