Link to home
Start Free TrialLog in
Avatar of shwanhamawandi
shwanhamawandiFlag for Iraq

asked on

How do I add (duration) for start Date and Time in Oracle 10G?

I have a table on Oracle 10g, with three columns ( Duration, start_date, start_time) as show below, I want to add two other columns contain stop_date and stop_time (by adding the duration to start_date and time)... Is there any way to implement such issue in Oracle 10g

Duration(sec)                start_date         start_time                                  stop_date         stop_time
- - - - - - - - - -               - - - - - - - -        - - - - - - -                                  - - - - - - - - -      - - - - - - -
620                              2008-07-11        09:15:36     >>>> should be       2008-07-11       09:25:56        
1118                            2008-07-14        16:55:22     >>>> should be       2008-07-14       17:14:00
259                             2008-07-20         23:58:43     >>>> should be       2008-07-21        00:03:02  

THANKS    
SOLUTION
Avatar of Tyler Laczko
Tyler Laczko
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shwanhamawandi

ASKER

I will read and try the mentioned solutions in your links and I will reply as soon as I test it, thanks anyway...
Note: I prefered a direct solution regarding this issue but it seems it different according the data types and requirements...
 
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i think the user wants to have actual data to be able to access.

you can use sdstuber's information to fill your columns:

::quote
create or replace view my_view as
select duration,start_date,start_time, to_char(to_date(start_date || ' ' || start_time,'yyyy-mm-dd hh24:mi:ss') + duration/86400),'yyyy-mm-dd') stop_date,
 to_char(to_date(start_date || ' ' || start_time,'yyyy-mm-dd hh24:mi:ss') + duration/86400),'hh24:mi:ss') stop_time
hi sdstuber,
thanks alot for your idea, my question was already a veiw to seperate the start_date and start_time... The original data in the table is as follow:
Columan      Type                Size
sts_date        varchar2        (14 byte)
Regarding your solution, I had create another view depends on the first veiw data, and I used your solution exactly as it has been mentioned above, the syntax has a simple problem but it works successfully when I remove ' ) ' after first and second 86400 values, stop_date and stop_time, and it becomes as attached
select duration,start_date,start_time, to_char(to_date(start_date || ' ' || start_time,'yyyy-mm-dd hh24:mi:ss') + duration/86400),'yyyy-mm-dd') stop_date,
 to_char(to_date(start_date || ' ' || start_time,'yyyy-mm-dd hh24:mi:ss') + duration/86400),'hh24:mi:ss') stop_time
Thanks


select duration,start_date,start_time, to_char(to_date(start_date || ' ' || start_time,'yyyy-mm-dd hh24:mi:ss') + duration/86400,'yyyy-mm-dd'),
 to_char(to_date(start_date || ' ' || start_time,'yyyy-mm-dd hh24:mi:ss') + duration/86400,'hh24:mi:ss')

Open in new window

Avatar of Sean Stuber
Sean Stuber

glad I could help!