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?
我使用Oracle数据库。在我的表中,我有一列类型为Timestamp的列,另一列是持有小时数的Int列。我如何从其他Timestamp列中减去这些小时数?
Meanwhile I have something like that:
同时我有类似的东西:
SELECT (START_TIME - interval 'CLOSING_HOURS' HOUR) as CLOSING_TIME
FROM APP.TRUMPS
1 个解决方案
#1
3
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.
numtodsinterval是将存储在表(或PL / SQL变量)中的小时数转换为可以从时间戳中减去的区间的最简单方法。
#1
3
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.
numtodsinterval是将存储在表(或PL / SQL变量)中的小时数转换为可以从时间戳中减去的区间的最简单方法。