DATE and DATETIME data types

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

MySQL provides the following data type to store dates:

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, MySQL can convert quoted strings to datetime data according the ISO datetime format ( YYYY-MM-DD hh:mm:ss' ).

Date arithmetic

Solution

MySQL has the same DATE data type as Informix ( year, month, day ). So you can use MySQL DATE data type for Informix DATE columns.

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

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

Important: MySQL version older than 5.6.4 and MariaDB versions older than 5.3.0 do not support fractional part of DATETIME. If you try to store a DATETIME x TO FRACTION(P) with such old server version, the fractional part is lost.

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