TIMESTAMP function is one of the data type in DB2. It helps you get TIMESTAMP in your SQL Query result. This is so common in any business scenario.
All business transactions linked to TimeStamp. Every business SQL query has TIME, DATE, and TIMESTAMP. My query here to show how to insert values to TIMESTAMP Column.
Definition for TIMESTAMP
A timestamp is a seven-part value representing a date and time by year, month, day, hour, minute, second, and microsecond, in the range of 0001-01-01-00.00.00.000000000 to 9999-12-31-24.00.00.000000000 with nanosecond precision. Timestamps can also hold timezone information.
Examples for TIMESTAMP function in DB2.
The TIMESTAMPS in your SQL Query, you can give in different formats.
The order is Abbreviation>DATE>Time
But you need to remember that TIME is part of TIMESTAMP. Here, our focus is TIMESTAMP.
Below SQL Query is the best example to create a DB2 table that uses TIMESTAMP
CREATE TABLE TABLE1 (C1 TIMESTAMP WITH TIME ZONE, C2 TIMESTAMP);
The another SQL query to insert values into DB2 Table
INSERT INTO TABLE1 VALUES ( '2007-11-05-08.00.00-08:00', '2007-11-05-08.00.00');
The general thumb rule:
A date, time, or timestamp value can be compared with another value of the same data type, a datetime constant of the same data type, or with a string representation of a value of that data type. Additionally, a TIMESTAMP WITHOUT TIME ZONE value can be compared with a TIMESTAMP WITH TIME ZONE value.