SQL DATEPART Function

Example

Return a specified part of a date:

SELECT DATEPART(year, '2017/08/25') AS DatePartInt;

Definition and Usage

The DATEPART() function returns a specified part of a date.

This function returns the result as an integer value.

Syntax

DATEPART(interval, date)

Continue reading SQL DATEPART Function

SQL DATENAME Function

Example

Return a specified part of a date:

SELECT DATENAME(year, '2017/08/25') AS DatePartString;

Definition and Usage

The DATENAME() function returns a specified part of a date.

This function returns the result as a string value.

Syntax

DATENAME(interval, date)

Continue reading SQL DATENAME Function