DATENAME

 

DATENAME returns part of a date as a string (text).

Syntax

DATENAME( <date-part>, <date> )

Details

  • Date Part — Determines the type of units to extract from the date (see below).
  • Date — The date to retrieve a part from.
Date Parts
  • Year — yy (or yyyy)
  • Month — m (or mm)
  • Day — d (or dd)
  • Hour — hh
  • Minute — mi (or n)
  • Quarter — q (or qq)
  • Day of Year — dy (or y)
  • Week — wk (or ww)
  • Weekday — dw (or weekday)

Examples

The day of the week for the current date:

DATENAME(weekday,GETDATE())

For the date 1/1/2000, this would return "Saturday"

Resources