Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Time format subtraction

Time format subtraction

From: <i5ha_at_yahoo.com>
Date: 6 Jan 2007 06:14:46 -0800
Message-ID: <1168092886.352706.151340@i15g2000cwa.googlegroups.com>


Hi everyone,
I'm trying to subtract some times so as to get the average time interval for a job, but the problem is that my database has the times stored in the formats as shown here: 11:00:00AM, 9:00:00PM, 5:30:00PM and so on. How can I subtract these times? I can't do it directly, i.e "Select to_timestamp(Session_start) - To_timestamp(Session_end) from session" because I'm getting error messages due to the 'AM' and 'PM' found in the times(I think). So I thought of a cursor (again...) that would add 12hours to the PM times, and then I could delete the 'AM' and
'PM' strings from my table and do my calculation, but then I'm having
error messages. My cursor is displayed below but is there a simpler method to do this? Please advice.

Declare
Cursor c_stime is
Select Session_start from session where Session_start LIKE
'________PM' or Session_start LIKE '_______PM';

Begin
For everyrec in c_stime Loop
Update session set Session_start = To_timestamp(everyrec.Session_start,
'HH24:MI:SS') + interval '+00 12:00:00' day to second;
End loop;
Commit;
End;

ERROR at line 1:
ORA-01830: date format picture ends before converting entire input string
ORA-06512: at line 7

Thaanks Received on Sat Jan 06 2007 - 08:14:46 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US