xan
xan

Reputation: 7568

How to combine date and time into a timestamp in db2?

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

Upvotes: 16

Views: 34867

Answers (2)

xan
xan

Reputation: 7568

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

Upvotes: 2

user1919238
user1919238

Reputation:

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

Upvotes: 34

Related Questions