How to combine date and time into a timestamp in db2?
29,911
Solution 1
The timestamp
function can be called with two arguments, one of which is date and one of which is time:
select timestamp(date_col,time_col) from your_table
Solution 2
As per this thread, the [TIMESTAMP][2]
function can accept 2 parameters, so you can simply pass it the DATE
and TIME
components and it constructs the TIMESTAMP
for you.
SELECT MyDate,
MyTime,
TIMESTAMP(MyDate, MyTime) AS MyTimestamp
FROM MyTable
Comments
-
xan about 4 years
In a
db2
database I have aDATE
column and aTIME
column, how can you combine these into a singleTIMESTAMP
? -
xan about 11 yearsFantastic, that is super handy :)