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').
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.
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.
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.
Result interval | Computation using the difference between two timestamps as a number of days |
---|---|
Years | integer value of (days/365) |
Quarters | integer value of (days/90) |
Months | integer value of (days/30) |
Weeks | integer value of (days/7) |
Days | integer value of days |
Hours | integer value of (days*24) |
Minutes (the absolute value of the number of days must not exceed 1491308.0888888888888882) | integer value of (days*24*60) |
Seconds (the absolute value of the number of days must be less than 24855.1348148148148148) | integer value of (days*24*60*60) |
Microseconds (the absolute value of the number of days must be less than 0.02485513481481481) | integer value of (days*24*60*60*1000000) |
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.