DATENAME

Returns a character string that represents the specified datepart of the specified date.

Syntax

DATENAME ( datepart , date )

Arguments

datepart

Is the part of the date to return. The following table lists all valid datepart arguments. User-defined variable equivalents are not valid.

_datepart_

Abbreviations

year

yy, yyyy

quarter

qq, q

month

mm, m

dayofyear

dy, y

day

dd, d

week

wk, ww

weekday

dw, w

hour

hh

minute

mi, n

second

ss, s

millisecond

ms

microsecond

mcs

nanosecond

ns

TZoffset

tz

ISO_WEEK

ISOWK, ISOWW

date

Is an expression that can be resolved to a time, date, smalldatetime, datetime, datetime2, or datetimeoffset value. date can be an expression, column expression, user-defined variable, or string literal. To avoid ambiguity, use four-digit years.

Return types

nvarchar

Example

SELECT DATENAME(dayofyear,'2007-10-30 12:15:32.123456789');

See Also