In SQL Server, DATETIME data type stores date and time with milliseconds accuracy. In PostgreSQL, you can use TIMESTAMP(3) data type.
SQL Server:
-- Sample table with DATETIME with milliseconds accuracy CREATE TABLE specs ( item VARCHAR(30), created_dt DATETIME );
PostgreSQL:
-- Sample table with TIMESTAMP with milliseconds accuracy CREATE TABLE specs ( item VARCHAR(30), created_dt TIMESTAMP(3) );
Conversion summary:
SQL Server | PostgreSQL | |
Syntax | DATETIME | TIMESTAMP(3) |
Date range | 1753-01-01 to 9999-12-31 | 4713 BC to 294276 AD |
For more information, see SQL Server to PostgreSQL Migration.