Onca
Onca

Reputation: 1135

SQL Oracle Timestamp - arithmetic between two columns

I use Oracle database. In my table, I have one column of type Timestamp, and another Int column which holds amount of hours. How I subtract those hours from the other Timestamp column?

Meanwhile I have something like that:

SELECT (START_TIME - interval 'CLOSING_HOURS' HOUR) as CLOSING_TIME 
 FROM APP.TRUMPS

Upvotes: 2

Views: 715

Answers (1)

Justin Cave
Justin Cave

Reputation: 231661

You probably want

SELECT start_time - numtodsinterval( closing_hours, 'hour' ) as closing_time
  FROM app.trumps

numtodsinterval is the easiest way to convert a number of hours stored in a table (or a PL/SQL variable) into an interval that you can subtract from your timestamp.

Upvotes: 3

Related Questions