Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help converting this SQL statement to use Oracle

Status
Not open for further replies.

PeasNCarrots

Programmer
Jun 22, 2004
73
US
So I need equiv of IIF for Oracle (I think it is Decode??)
and I need equiv of DateAdd (which can subtract days,months,yrs,weeks,etc.. from Value)


IIF([DOW_CD]='2', DateAdd("d",-5,WND_DT), IIF([DOW_CD]='3', DateAdd("d",-4,WND_DT), IIF([DOW_CD]='4', DateAdd("d", -3,[WND_DT]), IIF([DOW_CD]='5',DateADD("d",-2,[WND_DT]), IIf([DOW_CD]='6',DateAdd("d",-1,[WND_DT]), [WND_DT])))))
 
I don't understand this syntax completely, but
1. IIF Oracle analog is CASE
2. I suppose that you don't need it, because this is the same as
DateAdd("d",-7+DOW_CD,WND_DT)

If I'm misaken, please describe the result you need in English, not SQL.

Regards, Dima
 
So how would I convert this to ORACLE PLSQL?

DateAdd("d",-7+DOW_CD,WND_DT)
 
Assuming WND_DT is of DATE data type and DOW_CD is numeric or at least a string representing integer

WND_DT-7+DOW_CD

This adds DOW_CD days to WND_DT date and then subtracts 7 from the result (last week?). Is that what you need?


Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top