how to get year from a date in sql code example Example: sql convert datetime to year select YEAR(getdate()) /* 2020 */