DAY

Date & Time Functions
(4.9/5)

Returns the day of the month corresponding to a date. Extracts the day component (1-31) from a date serial number, essential for date analysis, age calculations, and day-based operations.

Interactive Formula Tester

=DAY("")

Complete Theory & Understanding

Master the fundamentals of Excel DAY function

Core Concept

The DAY function extracts the day component from a date serial number, returning a value between 1 and 31. This function is fundamental for date analysis, enabling day-based calculations, age calculations, and date component manipulation. DAY works with Excel's date serial number system where dates are stored as numbers.

Why Use DAY?

  • Extract day component for precise age and birthday calculations
  • Analyze data by day of month for patterns and trends
  • Implement day-based business rules and validations
  • Validate dates and check date ranges based on day values

Key Characteristics

Day Extraction

Extracts the day component (1-31) from any valid date, representing the day of the month.

DAY("2024-01-15") → 15

Variable Return Range

Returns a number between 1 and 31, varying based on the month length and the specific date.

DAY("2024-02-29") → 29 (leap year), DAY("2024-02-28") → 28

Date Serial Number Support

Works with Excel's date serial number system, accepting dates in various formats including serial numbers, date strings, and cell references.

DAY(45310) → 15 (for Jan 15, 2024)

Error Handling

Returns #VALUE! for invalid dates, ensuring data integrity in calculations and preventing silent errors.

DAY("invalid") → #VALUE!

Function Anatomy

=DAY(parameters...)
Required
Parameters:

Function-specific parameters

Returns
Return Value:

Function-specific return type

Primary Use Cases

Age Calculations

Extract day component for precise age and birthday calculations

Date Analysis

Analyze data by day of month for patterns and trends

Business Day Logic

Implement day-based business rules and validations

Date Validation

Validate dates and check date ranges based on day values

Theory Summary

Precise

Exact matching required

Position-Based

Returns numeric position

Error-Safe

Handles missing text gracefully

Syntax & Parameters

=DAY(serial_number)
Required
serial_number:

The date for which you want to find the day. Can be a date serial number, date string, or cell reference containing a date.

Returns
Return Value:

The day of the month as a number (1-31)

Description: Extracts the day component from a date

Interactive Examples

Basic DAY Function

Extract day from a specific date

"Date: 2024-01-15"
=DAY("2024-01-15")
15

Returns 15 for the 15th day of the month. DAY extracts the day component from the date serial number.

VBA Implementation & Automation

Basic DAY in VBA

Using DAY function in VBA

Sub DAYExample()
    Dim result As Integer
    Dim myDate As Date
    
    myDate = DateValue("2024-01-15")
    result = Day(myDate)
    
    Range("A1").Value = result
    MsgBox "DAY(2024-01-15) = " & result
End Sub

' Extract day from cell
Sub ExtractDayFromCell()
    Dim cellValue As Date
    Dim dayValue As Integer
    
    cellValue = Range("A1").Value
    dayValue = Day(cellValue)
    
    Range("B1").Value = dayValue
End Sub

' Loop through dates and extract days
Sub ExtractDaysFromRange()
    Dim cell As Range
    Dim dayVal As Integer
    
    For Each cell In Range("A1:A10")
        If IsDate(cell.Value) Then
            dayVal = Day(cell.Value)
            cell.Offset(0, 1).Value = dayVal
        End If
    Next cell
End Sub

Business Applications

Age Calculations

Extract day component for age calculations

=DAY(A1)

Date Analysis

Analyze patterns by day of month

=DAY(A1)

End of Month Check

Determine if date is month end

=DAY(A1)=DAY(EOMONTH(A1,0))

Business Day Logic

Implement day-based business rules

=IF(DAY(A1)<=15, "First Half", "Second Half")

Common Issues & Solutions

#VALUE! Error

DAY returns #VALUE! error

=DAY("invalid date")

Solution: Ensure the argument is a valid date. Check that the cell contains a date serial number, not text. Use DATEVALUE() to convert text dates, or verify cell formatting is set to Date.

Unexpected Day Numbers

DAY returns unexpected values

=DAY(A1)

Solution: Verify the input is actually a date. Text that looks like dates may be interpreted incorrectly. Ensure cells are formatted as dates and contain valid date values. Use ISDATE() to verify before using DAY.

Day Display as Number

Want day with suffix (1st, 2nd, 3rd)

=DAY(A1)

Solution: Use custom formatting or TEXT function with DAY. For ordinal suffixes, use: =DAY(A1)&IF(OR(DAY(A1)={1,21,31}),"st",IF(OR(DAY(A1)={2,22}),"nd",IF(OR(DAY(A1)={3,23}),"rd","th")))

Performance Tips & Best Practices

⚡ Performance Optimization

  • DAY is computationally efficient, using simple arithmetic extraction
  • Avoid using DAY in array formulas with large datasets when possible
  • Use DAY with cell references rather than recalculating repeatedly
  • Consider caching DAY results for frequently accessed dates

🎯 Best Practices

  • Use DAY for extracting day components from dates
  • Combine DAY with MONTH and YEAR for complete date analysis
  • Validate dates before using DAY to prevent errors
  • Use DAY with TODAY() for current day calculations
  • Consider EOMONTH for end-of-month calculations