Search code examples
sqlpostgresqlnullquotessql-insert

How to write null value to datetime array in PostgreSQL 8.3?


I try to execute query:

INSERT INTO table_name
(
  timedate_array_field
)
VALUES
(
  '{NULL, NULL}'
)

But I get error "Could not convert string to DateTime: 'null'".


Solution

  • Just add single quotes for the value:

    INSERT INTO table_name (timedate_array_field)
    VALUES ('{NULL, NULL}')

    -> SQLfiddle

    BTW, the data type is not called "DateTime" or "timedate" in Postgres, but timestamp.