DATENAME
Function
Returns a human-readable text string representing the specified part of a date. Month and day names (like "January" and "Monday") are returned according to the local computer's culture settings. Other date parts are returned as numbers that have been converted to strings.
Syntax
DATENAME(date-part, date)
Parameters
-
date-part: text
One of the following predefined strings. Each date-part has abbreviated aliases that can be used in place of the longer names without affecting the behavior.year
,yy
,yyyy
quarter
,qq
,q
month
,mm
,m
dayofyear
,dy
,y
day
,dd
,d
week
,wk
,ww
weekday
,dw
hour
,hh
minute
,mi
,n
second
,ss
,s
millisecond
,ms
- date: text
A text value that can be parsed into a date/time.
Return Value
A string containing the part of date that is specified by date-part.Example
-- The following examples assume a US English computer.
-- In other locales, DATENAME() will return locale-specific names.
PRINT DATENAME('month', '2016-07-23'); -- "July"
PRINT DATENAME('weekday', '2016-07-23'); -- "Saturday"
PRINT DATENAME('dd', '2016-07-23'); -- "23"