Excel DAY Function

The Excel DAY function returns the day from a specified date

Example: Excel DAY Function

Excel DAY Function

METHOD 1. Excel DAY Function using hardcoded values

EXCEL

=DAY("15/03/2017")
Result in cell C5 (15) - in this example we are inserting the date directly into the Excel DAY function, which returns the day component of the date.

METHOD 2. Excel DAY Function using links

EXCEL

=DAY(B5)
Result in cell C5 (15) - in this example we are referencing to a cell that contains a date and the Excel DAY function returns the day component of the date.

METHOD 3. Excel DAY function using the Excel built-in function library with hardcoded values

EXCEL

Formulas tab > Function Library group > Date & Time > DAY > populate the input box

=DAY("15/03/2017")
Note: in this example we are manually populating the input box with the date from which we want to return the day component. If entering the date directly into the input box, as per this example, we need to use the double quotation marks.
Built-in Excel DAY Function using hardocded values

METHOD 4. Excel DAY function using the Excel built-in function library with links

EXCEL

Formulas tab > Function Library group > Date & Time > DAY > populate the input box

=DAY(B5)
Note: in this example we are populating the input box with a cell reference that captures the date from which we want to return the day component.
Built-in Excel DAY Function using links

METHOD 1. Excel DAY function using VBA with hardcoded values

VBA

Sub Excel_DAY_Function_Using_Hardcoded_Values()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("DAY")
'apply the Excel DAY function
ws.Range("C5") = Day("15/03/2017")

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named DAY.

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.

METHOD 2. Excel DAY function using VBA with links

VBA

Sub Excel_DAY_Function_Using_Links()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("DAY")
'apply the Excel DAY function
ws.Range("C5") = Day(ws.Range("B5"))

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named DAY.
Date: If using this exact VBA code, which sources the date from cell ("C5"), you will need to capture the date from which you want to extract the day in cell ("C5").

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Date: Select the date from which you want to extract the day by changing the cell reference ("C5") to any cell in the worksheet that contains the date and doesn't conflict with the formula.

Usage of the Excel DAY function and formula syntax

EXPLANATION

DESCRIPTION
The Excel DAY function returns the day from a specified date.
SYNTAX
=DAY(serial_number)

ARGUMENTS
serial_number: (Required) The date from which you want to extract the day from.