Chapter 8 SQL Functions
329
date-part The date-part to be named.
$ For a complete listing of allowed date-parts, see "Date parts" on
page 306.
date-expression The date for which the date-part name is to be returned.
The date must contain the requested date-part.
The following statement returns the value May.
SELECT datename( month , ’1987/05/02’ )
DATENAME returns a string, even if the result is numeric, such as 23 for
the day.
♦
SQL/92 Transact-SQL extension.
♦
Sybase Compatible with Adaptive Server Enterprise.
DATEPART function [Date and time]
Returns the value of part of a datetime value.
DATEPART (
date-part
,
date-expression
)
date-part The date-part to be returned.
$ For a complete listing of allowed date-parts, see "Date parts" on
page 306.
date-expression The date for which the part is to be returned. The date
must contain the date-part field.
The following statement returns the value 5.
SELECT datepart( month , ’1987/05/02’ )
♦ SQL/92 Transact-SQL extension.
♦
Sybase Compatible with Adaptive Server Enterprise.
DATETIME function [Date and time]
Converts an expression into a timestamp.
DATETIME (
expression
)
expression The expression to be converted. It is generally a string.
Attempts to convert numerical values return an error.
Parameters
Example
Usage
Standards and
compatibility
Function
Syntax
Parameters
Example
Standards and
compatibility
Function
Syntax
Parameters