DAY Function - SQL Server to PostgreSQL Migration

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

SQL Server:

  -- Get the day
  SELECT DAY('2022-12-28'); 
  # 28

PostgreSQL:

  -- Get the day
  SELECT EXTRACT(DAY FROM DATE '2022-12-28'); 
  # 28

For more information, see SQL Server to PostgreSQL Migration.