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

Rumman Ansari   Software Engineer   2024-07-21 09:41:55   5587  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

Syntax:

<span class="pln">
</span><span class="typ">Day</span><span class="pun">()</span><span class="pln">
</span>

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

Code:

<span class="pln">
</span><span class="typ">Select</span><span class="pln"> DAY</span><span class="pun">(</span><span class="pln">GETDATE</span><span class="pun">())</span><span class="pln"> 
</span>

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

Code:

<span class="pln">
</span><span class="typ">Select</span><span class="pln"> DAY</span><span class="pun">(</span><span class="str">'01/31/2012'</span><span class="pun">)</span><span class="pln"> 
</span>

Output:

The above code will produce the following result-

<span class="pln">
</span><span class="lit">31</span><span class="pln">
</span>

No Questions Data Available.
No Program Data.

Stay Ahead of the Curve! Check out these trending topics and sharpen your skills.