datename

Description

Returns the name of the specified part of a datetime value.

Syntax

datename (datepart, date)

Parameters

datepart

is a date part or abbreviation. For a list of the date parts and abbreviations recognized by Adaptive Server, see “Date parts”.

date

can be either the function getdate, a character string in an acceptable date format, an expression that evaluates to a valid date format, or the name of a datetime or smalldatetime column.

Examples

Example 1

This example assumes a current date of November 20, 2000:

select datename(month, getdate())

November

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Any user can execute datename.

See also

Datatypes Date and time datatypes

Commands select, where clause

Functions dateadd, datename, datepart, getdate