Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Adding minutes to a date

user5716448May 8 2017 — edited May 10 2017

Hi,

Using 11.2.0.3 and have 3 tables 1 with date of arrival in in it and wish to compare this to tables which tell us if item has arrived in time

e.g planned_arrival and actual arrivals are  dates  assuming planned arrival is 21:00:00 and actual arrival is 21:40:00 and the other table b contains value and unit e.g. 30 as value and unit as Mins such that if actual_arrival > planned_arrival + 30 minutes then late.

If we say planned_arrival + 30 then it adds 30 days to it.  If was hard-coded sql could use planned_arrival+ interval '30' minute but how can we do this dynamically - needs to be able to run as sql rather than setting up string and using execute immediate to run dynamic sql.

table2 has different values for each custiomer e.g some coudl be 2 hours, some 30 minutes etc.

select  actual_arrival, planned_arrival + target_value

from table1 t

, table2 b

where t.customer = b.owner_name

Thought about using  planned_arrival + target/  case when unit = 'Mins' then 1440 when hours etc.  which woudl give us what we need but wondreded if better way to achive this.

Thanks

This post has been answered by Chris Hunt on May 8 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2017
Added on May 8 2017
7 comments
18,174 views