How to Use DAY in Excel
The DAY function is one of Excel's fundamental date functions that extracts the day component from a date value. It returns an integer between 1 and 31, representing the day of the month. While...
Key Insights
- The DAY function extracts the day number (1-31) from any valid Excel date, making it essential for date-based calculations and conditional logic in spreadsheets.
- Combining DAY with DATE, MONTH, and YEAR functions unlocks powerful date manipulation capabilities like calculating payment cycles, finding month-end dates, and building dynamic date formulas.
- Most DAY function errors stem from text-formatted dates or invalid date values—wrapping DAY in IFERROR or using DATEVALUE fixes 90% of common issues.
Introduction to the DAY Function
The DAY function is one of Excel’s fundamental date functions that extracts the day component from a date value. It returns an integer between 1 and 31, representing the day of the month. While simple in concept, DAY becomes incredibly powerful when combined with conditional logic, other date functions, and data analysis workflows.
The syntax is straightforward:
=DAY(serial_number)
The serial_number argument accepts any valid Excel date—whether it’s a cell reference containing a date, a date entered as text, or the result of another function that returns a date value. Excel stores dates as serial numbers internally (where January 1, 1900 is 1), so the DAY function extracts the day portion from this serial representation.
Common use cases include tracking payment due dates, filtering transactions by day of month, calculating aging reports, scheduling recurring tasks, and building dynamic date-based formulas for financial models.
Basic DAY Function Examples
Let’s start with fundamental applications. The most common usage involves extracting the day from a cell containing a date:
=DAY(A2)
If cell A2 contains 3/15/2024, this formula returns 15. The function works regardless of how you’ve formatted the date for display—it operates on the underlying serial number.
You can also pass dates directly as text strings:
=DAY("2024-03-15")
This returns 15. Excel automatically converts the text string to a date serial number before extracting the day. However, be cautious with text date formats—they must be recognizable by Excel based on your regional settings.
To get the current day of the month dynamically:
=DAY(TODAY())
If today is March 15, this returns 15. The formula updates automatically each day, making it useful for dashboards and reports that need to reflect current information.
You can also use DAY with the NOW function for timestamps:
=DAY(NOW())
This extracts the day from the current date and time. Since NOW includes time, but DAY only cares about the date portion, the time component is ignored.
Combining DAY with Other Date Functions
The real power of DAY emerges when you combine it with DATE, MONTH, YEAR, and other date functions. This enables sophisticated date manipulation without complex formulas.
To add a specific number of days to a date while preserving the month and year structure:
=DATE(YEAR(A2), MONTH(A2), DAY(A2)+7)
If A2 contains 3/15/2024, this returns 3/22/2024. While you could simply use =A2+7 for this specific example, the explicit approach becomes valuable when you need to manipulate individual date components separately.
Finding the last day of a month is a common requirement:
=DAY(EOMONTH(A2,0))
If A2 contains any date in March 2024, this returns 31. The EOMONTH function finds the last day of the month (offset by 0 months), and DAY extracts the day number. This is particularly useful for financial calculations, billing cycles, and report period definitions.
To reconstruct a date while modifying specific components:
=DATE(YEAR(A2), MONTH(A2)+1, DAY(A2))
This takes a date and moves it forward one month while keeping the same day. If A2 is 3/15/2024, the result is 4/15/2024. This pattern is essential for subscription billing, recurring payments, and schedule projections.
You can also use DAY to validate whether a date exists:
=DATE(YEAR(A2), MONTH(A2)+1, MIN(DAY(A2), DAY(EOMONTH(DATE(YEAR(A2), MONTH(A2)+1, 1), 0))))
This formula prevents invalid dates when adding months. If A2 is 1/31/2024 and you add one month, it correctly returns 2/29/2024 (2024 is a leap year) rather than an error.
Practical Applications and Use Cases
Let’s explore real-world scenarios where DAY solves actual business problems.
Payment Due Date Tracking: Suppose invoices are due on the 15th of each month. You can create an alert system:
=IF(DAY(TODAY())>=15, "Payment Due", "Payment Pending")
For more sophisticated tracking with days remaining:
=IF(DAY(TODAY())<15, 15-DAY(TODAY())&" days until payment due", "Payment overdue by "&(DAY(TODAY())-15)&" days")
Conditional Formatting Based on Day: Apply formatting to highlight rows where transactions occurred in the first 10 days of any month. Create a conditional formatting rule with this formula:
=DAY($B2)<=10
Apply this to your data range, with B2 being the first date cell. All rows with dates in the first 10 days will be highlighted.
Filtering Data by Specific Days: To extract all transactions that occurred on the 1st or 15th of any month:
=IF(OR(DAY(A2)=1, DAY(A2)=15), "Include", "Exclude")
Use this as a helper column for filtering, or incorporate it into more complex data analysis.
Age Calculation by Day: Calculate someone’s exact age in days:
=DAY(TODAY())-DAY(A2)
This only works within the same month. For accurate day differences, use =TODAY()-A2, but DAY becomes useful when you need the day component for specific business logic.
Recurring Schedule Builder: Create a formula that identifies the second Tuesday of every month for recurring meetings:
=DATE(YEAR(TODAY()), MONTH(TODAY()), 1+MOD(10-WEEKDAY(DATE(YEAR(TODAY()), MONTH(TODAY()), 1)), 7))
While this doesn’t directly use DAY, you’d use DAY to extract and validate the calculated date.
Common Errors and Troubleshooting
The DAY function is simple, but you’ll encounter errors when working with inconsistent data sources.
#VALUE! Error: This occurs when Excel can’t interpret the input as a date:
=DAY("March 15, 2024") // May work or fail depending on regional settings
=DAY("15/03/2024") // May fail in US Excel (expects MM/DD/YYYY)
Fix this with DATEVALUE:
=DAY(DATEVALUE("March 15, 2024"))
Or use IFERROR to handle unpredictable data:
=IFERROR(DAY(A2), "Invalid Date")
#NUM! Error: This appears when the date value is outside Excel’s valid range (before January 1, 1900, or after December 31, 9999):
=DAY(-1) // Returns #NUM! error
Text-Formatted Dates: If dates are stored as text, DAY may return unexpected results or errors. Convert them first:
=DAY(DATEVALUE(A2))
Or use VALUE if the text is already in serial number format:
=DAY(VALUE(A2))
Empty Cells: DAY of an empty cell returns 0, which may cause logic errors:
=IF(A2="", "", DAY(A2))
This prevents displaying 0 for blank cells.
Performance Tips and Best Practices
When working with large datasets (10,000+ rows), minimize volatile functions. While DAY itself isn’t volatile, combining it with TODAY() or NOW() forces recalculation on every sheet change.
Use Helper Columns: Instead of embedding complex DAY formulas in conditional formatting or array formulas, create a helper column:
=DAY(A2)
Then reference this column in your logic. This calculates once rather than repeatedly.
Avoid Unnecessary DAY Extraction: If you’re just comparing dates, don’t extract components:
// Inefficient
=IF(DAY(A2)=DAY(B2), "Same Day", "Different Day")
// Better for full date comparison
=IF(A2=B2, "Same Date", "Different Date")
Only use DAY when you specifically need the day component isolated from month and year.
Leverage Excel Tables: When using DAY in formulas within Excel Tables, structured references make formulas more readable:
=DAY([@InvoiceDate])
This is clearer than =DAY(A2) and adjusts automatically when rows are added or removed.
Consider Power Query for Complex Date Logic: For heavy date manipulation across large datasets, Power Query often outperforms worksheet formulas. Extract day components during data import rather than in the worksheet.
The DAY function is deceptively simple but indispensable for date-based business logic. Master it alongside MONTH, YEAR, and DATE, and you’ll handle virtually any date calculation Excel throws at you.