Returns the name of the specified part (such as the month “June”) of a date/time value, as a character string.
DATENAME ( date-part, date-expression )
date-part The date part to be named.
For a complete listing of allowed date parts, see “Date parts”.
date-expression The date for which the date part name is to be returned. The date must contain the requested date-part.
The following statement returns the value May:
SELECT DATENAME( MONTH , '1987/05/02' ) FROM iq_dummy
The following statement returns the value 722,001:
SELECT DATENAME(MICROSECOND, '2009-11-10 14:57:52.722001') FROM iq_dummy
The following statement returns the value 777,777:
SELECT DATENAME(MICROSECOND, '2000/07/07 07:07:07.777777') FROM iq_dummy
The following statement returns the value 33,189:
SELECT DATENAME(MCS, '2009-11-03 11:10:42.033189') FROM iq_dummy
DATENAME returns a character string, even if the result is numeric, such as 23, for the day.