Returns the specified datepart of the specified date or time as a character string.
datename(datepart {date | time | bigtime | datetime | bigdatetime})
declare @a bigdatetime select @a = "apr 12, 0001 00:00:00.010101" select datename(mm, @a) ------------------------------ April
select datename(month, getdate())
November
declare @a date select @a = "apr 12, 0001" select datename(mm, @a) ------------------------------ April
declare @a time select @a = "20:43:22" select datename(ss, @a) ------------------------------ 22
datename, a date function, returns the name of the specified part (such as the month “June”) of a datetime or smalldatetime value, as a character string. If the result is numeric, such as “23” for the day, it is still returned as a character string.
Takes a date, time, bigdatetime, bigtime, datetime, or smalldatetime value as its second argument
The date part weekday or dw returns the day of the week (Sunday, Monday, and so on) when used with datename.
Since smalldatetime is accurate only to the minute, when a smalldatetime value is used with datename, seconds and milliseconds are always 0.
See also select, where clause in Reference Manual: Commands.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute datename.