sql
Select only year from date field MSSql query
To extract year from a date in the MSSql Server you can use the year() method of MSSql.
SELECT year(date_column) as my_year FROM table_name;
In the above query, we have a table that has a date type column. When selecting this date type column we are only showing its date.
For example, If We have a table named Employee and it has a date type column Join_Date. To get the year from the Join_Date column we can use below MSSql Query.
SELECT
year(Join_Date) as join_year
FROM
Employee;
Was this helpful?
Similar Posts