Advertisement

07.21.2005 at 05:15PM PDT, ID: 21500335
[x]
Attachment Details

dateadd(datediff) equivalent in Oracle

Asked by fusebox in Oracle Database

Tags: oracle, datediff, dateadd

Hi,

I have the following function in which I created in Sybase but need to convert to Oracle and having difficulty, Any help would be greatly appreciated.

CREATE FUNCTION "AFM"."BRG_DATEFIXED"(in int_type char(4), in interval integer, in datefirsttodo date, date_last_comp date)
--ALTER FUNCTION "AFM"."BRG_DATEFIXED"(in int_type char(4), in interval integer, in datefirsttodo date, date_last_comp date)
returns date
    begin
        declare returnVal date;
       
        if int_type = 'M' then
            set returnVal = dateadd(mm,(floor(datediff(mm,datefirsttodo,date_last_comp)/interval)+1)*interval,datefirsttodo)
        elseif int_type = 'YYYY' then
            set returnVal = dateadd(yy,(floor(datediff(yy,datefirsttodo,date_last_comp)/interval)+1)*interval,datefirsttodo)
        elseif int_type = 'ww' then
            set returnVal = dateadd(wk,(floor(datediff(wk,datefirsttodo,date_last_comp)/interval)+1)*interval,datefirsttodo)
        elseif int_type  = 'q' then
            set returnVal =dateadd(qq,(floor(datediff(qq,datefirsttodo,date_last_comp)/interval)+1)*interval,datefirsttodo)
        elseif int_type = 'd' then
            set returnVal = dateadd(dd,(floor(datediff(dd,datefirsttodo,date_last_comp)/interval)+1)*interval,datefirsttodo)
        end if;
        return(returnVal)
    end  Start Free Trial
 
 
[+][-]07.21.2005 at 05:25PM PDT, ID: 14498731

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.21.2005 at 05:43PM PDT, ID: 14498797

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.21.2005 at 06:53PM PDT, ID: 14499066

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: oracle, datediff, dateadd
Sign Up Now!
Solution Provided By: jaspreet_bajaj
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.21.2005 at 07:18PM PDT, ID: 14499150

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.21.2005 at 07:24PM PDT, ID: 14499174

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2005 at 12:37PM PDT, ID: 14506102

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2005 at 01:04AM PDT, ID: 14509003

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32