Updated on 2025-06-30 GMT+08:00

Date and Time Data Types

Table 1 Date and Time Data Types

Data Type

Differences Compared with MySQL

DATE

None

DATETIME[(fsp)]

For details about the differences, see the description below the table.

TIMESTAMP[(fsp)]

GaussDB supports the timestamp data type. Compared with MySQL, GaussDB has the following differences in specifications:

  • In MySQL 5.7, the default value of the timestamp column is the real time when data is inserted. Same as MySQL 8.0, GaussDB has no default value set for this column. That is, when null is inserted, the value is null.
  • For other differences, see the description below the table.

TIME[(fsp)]

GaussDB supports the time data type. Compared with MySQL, GaussDB has the following differences in specifications:

  • When the hour, minute, second, and nanosecond of the time type are 0, the sign bits of GaussDB and MySQL may be different.
  • For other differences, see the description below the table.

YEAR[(4)]

GaussDB supports the year data type. Compared with MySQL, GaussDB has the following differences in specifications:

In MySQL 5.7, the year column is displayed as 'year(4)' by default. GaussDB is consistent with MySQL 8.0, displaying only 'year'.

  • GaussDB does not support ODBC syntax literals:

    { d 'str' }

    { t 'str' }

    { ts 'str' }

  • GaussDB supports standard SQL literals, and precision can be added after type keywords, but MySQL does not support the following:

    DATE[(n)] 'str'

    TIME[(n)] 'str'

    TIMESTAMP[(n)] 'str'

  • If you specify a precision for the DATETIME, TIME, or TIMESTAMP data type greater than the maximum precision supported by the data type, GaussDB truncates the precision to the maximum precision supported by the data type, whereas MySQL reports an error.