Home » SQL & PL/SQL » SQL & PL/SQL » Adding Time Value having varchar2 datatype (merged)
Adding Time Value having varchar2 datatype (merged) [message #390460] Fri, 06 March 2009 07:15 Go to next message
evk_87
Messages: 8
Registered: September 2008
Junior Member
column name: extra_hour
datatype: varchar2(5)

extra_hour
----------
01:30
01:30
00:00
02:45

and so on...

Problem: I want to add up all the given value and display it in a select statment, that is the output should be:

Output:

XXXXXX
----------
05:45

Kindly Help !!!

If any other alternative present, kindly reply, since i can change the table.
Re: Adding Time Value having varchar2 datatype (merged) [message #390462 is a reply to message #390460] Fri, 06 March 2009 07:38 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Post a Test case: create table and insert statements along with the result you want with these data.

Convert the string into seconds, add the seconds and convert back to a string (for instance using numtodsinterval function).

Regards
Michel

[Updated on: Fri, 06 March 2009 07:39]

Report message to a moderator

Re: Adding Time Value having varchar2 datatype (merged) [message #390463 is a reply to message #390460] Fri, 06 March 2009 07:41 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Forgot to mention that you should use INTERVAL DAY TO SECOND Datatype datatype instead of strings.

Regards
Michel
Re: Adding Time Value having varchar2 datatype (merged) [message #390493 is a reply to message #390463] Fri, 06 March 2009 10:26 Go to previous message
evk_87
Messages: 8
Registered: September 2008
Junior Member
working fine....thanks !!
Previous Topic: Joining two tables
Next Topic: Materialized View corrupted (merged)
Goto Forum:
  


Current Time: Thu Dec 08 20:10:29 CST 2016

Total time taken to generate the page: 0.09659 seconds