Comparing DATEPART and DATENAME

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.

These examples assume the date May 29:

SELECT DATEPART(month, GETDATE())

Here is the result set:

 
------------  
5  
(1 row(s) affected)
SELECT DATENAME(month, GETDATE())

Here is the result set:

-----------

 
May  
(1 row(s) affected)

See Also

Date and Time Functions

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.