title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | helpviewer_keywords | ||
---|---|---|---|---|---|---|---|---|---|---|
YEAR (SSIS Expression) |
YEAR (SSIS Expression) |
chugugrace |
chugu |
03/01/2017 |
sql |
integration-services |
conceptual |
|
[!INCLUDEsqlserver-ssis]
Returns an integer that represents the year datepart of a date.
YEAR(date)
date
Is a date in any date format.
DT_I4
YEAR returns a null result if the argument is null.
A date literal must be explicitly cast to one of the date data types. For more information, see Integration Services Data Types.
Note
The expression fails to validate when a date literal is explicitly cast to one of these date data types: DT_DBTIMESTAMPOFFSET and DT_DBTIMESTAMP2.
Using the YEAR function is briefer but equivalent to using the DATEPART("Year", date) function.
This example returns the number of the year in a date literal. If the date is in mm/dd/yyyy format, this example returns "2002".
YEAR((DT_DBTIMESTAMP)"11/23/2002")
This example returns the integer that represents the year in the ModifiedDate column.
YEAR(ModifiedDate)
This example returns the integer that represents the year of the current date.
YEAR(GETDATE())
DATEADD (SSIS Expression)
DATEDIFF (SSIS Expression)
DATEPART (SSIS Expression)
DAY (SSIS Expression)
MONTH (SSIS Expression)
Functions (SSIS Expression)