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
Share:
29,911
xan
Author by

xan

C#, SQL and and other shenanigans.

Updated on March 02, 2020

Comments

  • xan
    xan about 4 years

    In a db2 database I have a DATE column and a TIME column, how can you combine these into a single TIMESTAMP?

  • xan
    xan about 11 years
    Fantastic, that is super handy :)