YEAR Function - SQL Server to PostgreSQL Migration

In SQL Server, you can use YEAR function to get the year (an integer number) of the specified datetime. In PostgreSQL, you have to use EXTRACT(YEAR FROM datetime) function.

SQL Server:

  -- Get the year
  SELECT YEAR('2022-09-16'); 
  # 2022

PostgreSQL:

  -- Get the year
  SELECT EXTRACT(YEAR FROM DATE '2022-09-16'); 
  # 2022

For more information, see SQL Server to PostgreSQL Migration