The DATEPART and DATENAME functions produce the specified part of a datetime value ¾ the year, quarter, day, hour, and so on ¾ as either an integer or an ASCII string. Because smalldatetime is accurate only to the minute, when a smalldatetime value is used with either of these functions, the seconds and milliseconds returned are always zero.
The following examples assume the date May 29:
SELECT DATEPART(month, GETDATE()) |
|
------------ |
|
7 |
|
(1 row(s) affected) |
|
SELECT DATENAME(month, GETDATE()) |
|
----------- |
|
July |
|
(1 row(s) affected) |