A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: Functions: Date and Time Functions

datepart()

The Date & Time Function datepart() returns a fragment, i.e. a date part of a given date value.

Syntax of the Datatype Conversion Function datepart()

    datepart( date_part, date expression )
    

The parameter date_part of the Date & Time Function datepart()

date_part
The parameter "date_part" is a placeholder for the abbreviation of a fragment of a date value. (See also: date parts.)

date expression
The parameter "date expression" is a placeholder for a date which can be of the format of any of these datatypes: datetime, smalldatetime, date (starting with ASE® version 15.0), time (starting with ASE® Version 15.0) or as a character string in date format.

Example for the Datatype Conversion Function datepart()

    declare @a datetime
select @a = "Apr 12, 2006"
select datepart(mm, @a)
go
-----
April

Returns the written out name of the month for the given date.

See also:

ASE T-SQL - Aggregate Functions,
Date and Time Functions,
dateadd(),
datediff(),
datename(),
date_part,
day(),
getdate(),
month(),
style numbers,
year().