Find date parts as numbers or names

The datepart and datename functions produce the specified part of a datetime or smalldatetime value—the year, quarter, day, hour, and so on—as either an integer or an ASCII string. Since smalldatetime is accurate only to the minute, when a smalldatetime value is used with either of these functions, seconds and milliseconds are always 0.

The following examples assume an August 12 date:

select datepart(month, getdate()) 
--------------
            8 
 
(1 row affected) 
select datename(month, getdate()) 
------------- 
August
 
(1 row affected)