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!

Add hours and minutes to date

Sajeeva LakmalMar 6 2013 — edited Mar 7 2013
Hi,
I need to write a function which has two input parameters.
Parameter1 => Date data type, value is in GMT.
Parameter1 => String value which indicates the time offset and it has the following format.

GMT(sign)HH24Mi
for examples:
GMT+400 , GMT-1400

I need add the offset (param2) to the date (param1) and returns as the output.

I wrote a simple code but can't get it to work. I would like to know if there is an another way to do it.
create or replace
Function         F_FUNCTION_NAME(dt date,timeZoneOffset   in   varchar2)
return date
As
    offset  varchar2(9);    
Begin
    Offset := (To_Char(Substr(Substr(Timezoneoffset,4),0,Length(Substr(Timezoneoffset,4))-2)||':'||Substr(Substr(Timezoneoffset,4),-2)));
    return Dt + interval Offset hour to minute;
End;
Thank You.
This post has been answered by AlbertoFaenza on Mar 6 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2013
Added on Mar 6 2013
16 comments
14,345 views