Excel Formula To Get Total Days In A Month

Search
Generic filters

Table of Contents

Sometimes you need to calculate the total number of days in a month to use in the further calculation. It happens specifically when you work on templates and dashboards.

Sometimes you need to calculate the total number of days in a month to use in the further calculation.

It happens specifically when you work on templates and dashboards. So today, let me show you a simple formula that can do this for you.

To calculate the number of days in a given month from a date, we need to use a formula based on EOMONTH and DAY.

Formula: Get Total Days in Month

=DAY(EOMONTH(A2,0))

How this Formula Works

As you see this formula is a combination of two functions. We have EOMONTH which is covered within DAY.

  1. First, when you refer to a date and “0” in EOMONTH it returns the last date of that month. Here the date is on cell A2.
  2. Second, the DAY function returns the day from the last day returned by EOMONTH.

The day of the month’s last day is always the total number of days in a month. From 31-Mar-2017, it returns 31 which is the total number of days in the March month.

What Is Dynamic Formula?

Let’s you want to get total days in a month for the current month and you want this formula to return it automatically every time the month changes.

Formula will be:

=DAY(EOMONTH(TODAY(),0))

In this formula, instead of referring to a date, we have referred to TODAY in EOMONTH which returns the current date and then EOMONTH returns the last date from the current date’s month.

In the end, DAY returns the day number and gets the total number of days for the current month.

Get Days in Month using Month Name

Let’s say you have entered a month’s name in a cell not a proper date and now you want to calculate a total number of days from this month.

Formula will be:

=DAY(EOMONTH(DATEVALUE(“01-“&A2&”-“&YEAR(TODAY())),0))

This formula creates a first day’s date of the month you have mentioned and then EOMONTH returns the last date and DAY returns the last day which is the total number of days in a month.

You can use the month’s name both in short form and long-form.

We Create Your Life Easy With Our Free Excel Templates & Spreadsheet Dashboards

Use free Excel Templates, Tools and Dashboards to create and draft a professional looking dashboards and computation sheet for your personal and business use. You can Explore Calendars, Activity Planners, Invoice Templates, Sales Forecast Sheets, Budget templates and various business information delivering Templates in Excel and Spreadsheet at XLSX Templates. 

These templates, dashboards and tools are useful in various occasions. You can also customize these templates as per your requirement. Modification of fields and data source helps in making the template more relevant.

Learn Microsoft Excel : Blogs and Articles

Learn about various tips and tricks in Microsoft Excel and Spreadsheet. Create best templates and dashboards using free tricks and tutorials in excel and spreadsheet. These tutorial posts are useful for everyone who wants to master the skills in excel and spreadsheet.

Deselect Cells in Excel

How To Deselect Cells in Excel

Table of Contents How to Deselect Cells in Excel After adding the deselecting cells feature in Excel, this  becomes so  …

Select Non-Contiguous Cells in Excel

Learn how to Select Non-Contiguous Cells in Excel

Table of Contents Select cell without using Ctrl Key By following these simple steps we can do it. At first, …

Format Painter in Excel

How to use Format Painter in Excel

Table of Contents Where’s the Format Painter Button? It’s there on your Home Tab. If you look at the clipboard …

Apply Strikethrough in Excel [Shortcut + Command]

How to apply Strikethrough in Excel [Shortcut + Command]

Table of Contents Shortcut Key to Apply Strikethrough to a Cell Let’s say you’re in hurry and don’t want to …

Formula Bar in Excel

Formula Bar in Excel

Table of Contents Key Points To Consider Using Formula Bar You can hide or unhide the formula bar. You can …

Convert Date into Day

Convert Date into Day Sub date2day() Dim tempCell As Range Selection.Value = Selection.Value For Each tempCell In Selection If IsDate(tempCell) …

Basic VBA Macro Codes in Excel

Custom Header & Footer

Sub CustomHeader() Dim myText As String myText = InputBox(“Enter your text here”, “Enter Text”) With ActiveSheet.PageSetup .LeftHeader = “” .CenterHeader …

Get Macro Code

Add Header and Footer Date

Sub DateInHeader() With ActiveSheet.PageSetup .LeftHeader = “” .CenterHeader = “&D” .RightHeader = “” .LeftFooter = “” .CenterFooter = “” .RightFooter …

Get Macro Code

Open Calculator

Sub OpenCalculator() Application.ActivateMicrosoftApp Index:=0 End Sub In Windows, there is a specific calculator and by using this macro code you …

Get Macro Code

Unmerge Cells

Sub UnmergeCells() Selection.UnMerge End Sub Unmerge Cells code simply uses the unmerge options which you have on the HOME‌ tab. …

Get Macro Code

Remove Text Wrap

Sub RemoveTextWrap() Range(“A1”).WrapText = False End Sub This code will help you to remove text wrap from the entire worksheet …

Get Macro Code

Auto Fit Rows

Sub AutoFitRows() Cells.Select Cells.EntireRow.AutoFit End Sub You can use this code to auto-fit all the rows in a worksheet. When …

Get Macro Code

Auto Fit Columns

Sub AutoFitColumns() Cells.Select Cells.EntireColumn.AutoFit End Sub Use above Excel macro code to auto fit rows in all your sheet at …

Get Macro Code

Insert Multiple Columns

Sub InsertMultipleColumns() Dim i As Integer Dim j As Integer ActiveCell.EntireColumn.Select On Error GoTo Last i = InputBox(“Enter number of …

Get Macro Code

Insert Multiple Rows

Sub InsertMultipleRows() Dim i As Integer Dim j As Integer ActiveCell.EntireRow.Select On Error GoTo Last i = InputBox(“Enter number of …

Get Macro Code