Table of Contents

    How to Use the DAY() Function in SQL Server: A Comprehensive Guide

    How to Use the DAY() Function in SQL Server: A Comprehensive Guide

    Syntax:

    
    Day()
    

    Returns the 'Day number of the Month' of the given date

    Code:

    
    Select DAY(GETDATE()) 
    

    Returns the day number of the month, based on current system datetime.

    Code:

    
    Select DAY('01/31/2012') 
    

    Output:

    The above code will produce the following result-

    
    31