devang
devang

Reputation: 4527

convert query from sql to oracle

I have the following SQL query:

SELECT
@weekenddtm = CONVERT(VARCHAR,DATEADD(DD,(7 - DATEPART(DW,@p_end_dtm)),@p_end_dtm),111)

and I tried converting it into oracle using this query:

v_weekenddtm   := CAST(p_end_dtm + NUMTODSINTERVAL((7-TO_NUMBER(TO_CHAR(p_end_dtm,'D'))),'DAY')  AS DATE);

,but it is giving me error. Any idea how to go ahead?

Upvotes: 0

Views: 542

Answers (1)

Tony Andrews
Tony Andrews

Reputation: 132710

What are the datatypes of p_end_dtm and v_weekend_dtm? Your code works if they are as follows:

declare
   p_end_dtm timestamp;
   v_weekend_dtm date;
begin
   v_weekend_dtm := CAST(p_end_dtm+ NUMTODSINTERVAL((7-TO_NUMBER(TO_CHAR(p_end_dtm,'D'))),'DAY')  AS DATE);
end;

Upvotes: 1

Related Questions