Translate a CASE statement into a Stage Variable

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
dmotoc
Participant
Posts: 6
Joined: Mon Oct 13, 2008 11:30 am
Location: Canada

Translate a CASE statement into a Stage Variable

Post by dmotoc »

Hi there

I have the following Case statement that I need to translate in a Stage Variable

Code: Select all

case
            when substr(in_date_numeric, 7, 2) between '01' and
                
                 to_char(last_day(to_date(substr(in_date_numeric, 1, 6),
                                          'YYYYMM')),
                         'DD') 
             then
             to_date(in_date_numeric, 'YYYYMMDD')      
            else
             null        
          end      
         else
          null  
       end in_date

So far I manage to get something like that:

If string(in_date_numeric, 1, 4) between '0001' and '9999' and string(in_date_numeric, 5, 2) between '01' and '12'
then
(If string(in_date_numeric, 7, 2) between '01' and char(last_day(iconv(string(in_date_numeric, 1, 6),'YYYYMM')),'DD')
then iconv(in_date_numeric, 'YYYYMMDD') else null )
else null


I am not sure how the function last_day from Oracle will work in DataStage. Is something equivalent that can be used?

Thanks for your help
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

svYear          Left(InLink.TheDate, 4)
svIsLeapYear    Mod(svYear,4) = 0 And (Mod(svYear,100) <> 0 Or Mod(svYear,400) = 0)
svFebDays       If svIsLeapYear Then 29 Else 28
svMonthDays     "31|" : svFebDays : "|31|30|31|30|31|31|30|31|30|31"
svMonthNo       InLink.TheDate[5,2]
svLastDay       Field(svMonthDays, "|", svMonthNo, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dmotoc
Participant
Posts: 6
Joined: Mon Oct 13, 2008 11:30 am
Location: Canada

Re: Translate a CASE statement into a Stage Variable

Post by dmotoc »

it works, thanks!
Post Reply