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!

function to convert string to number

443975Oct 17 2005 — edited Oct 19 2005
Hi there,
I wrote a function which converted a hor minute component of a date to a number. Now I need to do the same with a string (because the hours could be more then 23:95). Anyway here is my function. How can I rewrite it so it will accept a string as in parameter. Somwhow I can not work it out. Thanks a lot.

Chris

function calculate_hours_project(in_hours in DATE)

RETURN number
AS
hrs CHAR(2);
mins CHAR(2);

BEGIN
hrs := to_char(in_day, 'HH24');
mins := to_char(in_day, 'MI');

if hrs is not null and mins is not null then
RETURN to_number(hrs + (mins/60));
else
RETURN 0;
end if;
END calculate_hours_project;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2005
Added on Oct 17 2005
7 comments
928 views