SMALLDATETIME Data Type - SQL Server to PostgreSQL Migration

In SQL Server, the SMALLDATETIME data type stores date and time values with minute-level accuracy (seconds are always 00).

In PostgreSQL, you can use the TIMESTAMP(0) data type along with a DATE_TRUNC expression to set the seconds to 00.

SQL Server:

  -- Sample table 
  CREATE TABLE products
  (
    name VARCHAR(30),
    created_dt SMALLDATETIME
  );
 
  INSERT INTO products VALUES ('Apple', GETDATE());
 
  -- Seconds are set to 00
  SELECT created_dt FROM products;
  /* 2026-01-14 16:28:00 */

PostgreSQL:

  -- Sample table 
  CREATE TABLE products
  (
    name VARCHAR(30),
    created_dt TIMESTAMP(0)
  );
 
  -- Use an expression to set seconds to 00 
  INSERT INTO products VALUES ('Apple', DATE_TRUNC('minute', NOW()));
 
  SELECT created_dt FROM products;
  /* 2026-01-14 16:28:00 */

For more information, see SQL Server to PostgreSQL Migration.