The DATE data type supports applications that use the Oracle DATE data type and expect that the DATE values include time information (for example,
'2009-04-01-09.43.05').
Enablement
You enable DATE as TIMESTAMP(0) support at the database level, before creating the database where you require the support.
To enable the support, set the DB2_COMPATIBILITY_VECTOR< registry variable to hexadecimal value 0x40 (bit position 7), and then stop and restart the instance
to have the new setting take effect.
db2set DB2_COMPATIBILITY_VECTOR=40
db2stop
db2start
To take full advantage of the Db2® compatibility features for Oracle applications, the recommended setting for the DB2_COMPATIBILITY_VECTOR is ORA,
which sets all of the compatibility bits.
After you create a database with DATE as TIMESTAMP(0) support enabled, the date_compat database configuration parameter is set to ON.
If you create a database with DATE as TIMESTAMP(0) support enabled, you cannot disable that support for that database, even if you reset the
DB2_COMPATIBILITY_VECTOR registry variable.
Similarly, if you create a database with DATE as TIMESTAMP(0) support disabled, you cannot enable that support for that database later, even by setting the
DB2_COMPATIBILITY_VECTOR registry variable.
Effects
The date_compat database configuration parameter indicates whether the DATE compatibility semantics associated with the TIMESTAMP(0) data type are applied to
the connected database.
The effects of setting date_compat to ON are as follows.
When the DATE data type is explicitly encountered in SQL statements,
it is implicitly mapped to TIMESTAMP(0) in most cases.
An exception is the specification of SQL DATE in the xml-index-specification clause of a CREATE INDEX statement.
As a result of the implicit mapping, messages refer to the TIMESTAMP data type instead of DATE, and any operations that describe data types for columns or
routines return TIMESTAMP instead of DATE.
Datetime literal support is changed as follows:
The CURRENT_DATE (also known as CURRENT DATE) special register returns a TIMESTAMP(0) value that is the same as the CURRENT_TIMESTAMP(0) value.
When you add a numeric value to a TIMESTAMP value or subtract a numeric value from a TIMESTAMP value, it is assumed that the numeric value represents a number
of days.
The numeric value can have any numeric data type, and any fractional value is considered to be a fractional portion of a day.
For example, TIMESTAMP '2008-03-28 12:00:00' + 1.3 adds 1 day, 7 hours, and 12 minutes to the TIMESTAMP value, resulting in '2008-03-29 19:12:00'.
If you are using expressions for partial days, such as 1/24 (1 hour) or 1/24/60 (1 minute), ensure that the number_compat database configuration parameter is set
to ON so that the division is performed using DECFLOAT arithmetic.
The results of some functions change:
If you use the import or load utility to input data into a DATE column, you must use the timestampformat file type modifier instead of the dateformat file
type modifier.
© Copyright IBM Corp.