MONTH Function - SQL Server to PostgreSQL Migration

In SQL Server, you can use MONTH function to get the month (an integer number 1-12) of the specified datetime. In PostgreSQL, you have to use EXTRACT(MONTH FROM datetime) function.

SQL Server:

  -- Get the month
  SELECT MONTH('2022-09-16'); 
  # 9

PostgreSQL:

  -- Get the month
  SELECT EXTRACT(MONTH FROM DATE '2022-09-16'); 
  # 9

For more information, see SQL Server to PostgreSQL Migration