DATE and DATETIME data types

Informix® provides two data types to store dates and time information:

PostgreSQL provides the following data type to store date and time information:

String representing date time information

Informix is able to convert quoted strings to DATE / DATETIME data if the string contents matches environment parameters (i.e. DBDATE, GL_DATETIME). As in Informix, PostgreSQL can convert quoted strings to date time data according to the DateStyle session parameter. PostgreSQL always accepts ISO date time strings.

Date arithmetic

Solution

The DATE type of PostgreSQL is equivalent to the DATE type in Informix ( stores year, month, day ). Use PostgreSQL DATE data type for Informix DATE columns.

PostgreSQL TIME(N) WITHOUT TIME ZONE data type can be used to store DATETIME HOUR TO ??? values.

PostgreSQL TIMESTAMP(N) WITHOUT TIME ZONE data type can be used to store DATETIME YEAR TO ??? values.

The SQL Translator of the PostgreSQL driver makes the following conversions automatically for the DATETIME types:
  • DATETIME HOUR TO MINUTE is converted to PostgreSQL TIME(0) WITHOUT TIME ZONE (seconds set to 00).
  • DATETIME HOUR TO SECOND is converted to PostgreSQL TIME(0) WITHOUT TIME ZONE.
  • DATETIME HOUR TO FRACTION(N) is converted to PostgreSQL TIME(N) WITHOUT TIME ZONE.
  • DATETIME YEAR TO MINUTE is converted to PostgreSQL TIMSTAMP(0) WITHOUT TIME ZONE (seconds set to 00).
  • DATETIME YEAR TO SECOND is converted to PostgreSQL TIMESTAMP(0) WITHOUT TIME ZONE.
  • DATETIME YEAR TO FRACTION(N) is converted to PostgreSQL TIMESTAMP(N) WITHOUT TIME ZONE.

Other DATETIME types will be mapped to PostgreSQL TIMESTAMP(N) types. Missing date or time parts default to 1900-01-01 00:00:00.

See also Date and time in SQL statements for good SQL programming practices.