Back to list SQL Server How to Get the Year from a Date in T-SQL Database: SQL Server Operators:YEAR() Problem: You’d like to get the year from a date field in a SQL Server database. Example: Our database has a table named Children with data in the columns Id, FirstName, LastName, and BirthDate. IdFirstNameLastNameBirthDate 1JaneSmith2018-06-20 2GaryBrown2010-02-02 3LoraAdams2014-11-05 Let’s get the year from each child’s birthdate. Solution: We’ll use the YEAR() function. Here’s the query you would write: SELECT FirstName, LastName, YEAR(BirthDate) AS BirthYear FROM Children; Here’s the result of the query: FirstNameLastNameBirthYear JaneSmith2018 GaryBrown2010 LoraAdams2014 Discussion: Use SQL Server’s YEAR() function if you want to get the year part from a date. This function takes only one argument – a date, in one of the date and time or date data types. (In our example, the column BirthDate is a date data type). The argument can be a column name or an expression. (In our example, the argument is the BirthDate column.) The YEAR() function returns an integer. For Jane Smith, it returns the integer 2018 from the birth date '2018-06-20'. Recommended courses: SQL Basics in SQL Server Common Functions in SQL Server Recommended articles: 5 SQL Functions for Manipulating Strings 18 Useful Important SQL Functions to Learn ASAP Performing Calculations on Date- and Time-Related Values How Often Employees Are Running Late for Work: SQL Datetime and Interval SQL Arithmetic See also: How to remove leading and/or trailing spaces of a string in T-SQL How to Remove Trailing Zeros from a Decimal in PostgreSQL Tags: SQL Server Subscribe to our newsletter Join our weekly newsletter to be notified about the latest posts.