Find date parts as numbers or names

The datepart and datename functions produce the specified part of a datetime, smalldatetime or date 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. If the time datatype is used, seconds and milleseconds are given.

The following examples assume an August 12 date:

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