SQL YEAR

The SQL YEAR() function is used to get the year of a date expression.

To get the year from a date: SQL YEAR Function.
To get the month from a date: SQL Month Function.
To get the day from a date: SQL Day Function.

SQL YEAR Syntax

SELECT YEAR(date-expression)

SQL YEAR Example

SELECT YEAR(NOW())

The result will look like: (Suppose it’s 2011 now)

2011
SELECT YEAR('2012-10-23T01:01:01.1234567-07:00')

The result will look like:

2012

In SQL Server:

SELECT YEAR(GETDATE())

The result will look like:

2011
SELECT YEAR(0)

The result will look like: (which is the base year)

1900

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>