Formating issue

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
badri
Participant
Posts: 19
Joined: Mon Jul 12, 2004 2:58 am

Formating issue

Post by badri »

Hi,

I have a date formating issue. The below stage validation returns correctly (Else part) if the PeriodNum is in double digit i.e. say 10152004

In the 'Else' part if the LNK1.periodNum is 3 then it should return 03152004 instead of 3152004


IF(LNK1.TRANSACTIONTYPE = '100' ) Then '1215' : (LNK1.Year - 1)
Else
LNK1.PeriodNum : '15' : LNK2.Year

Without going for OConv is there any other logic.

Thanks in Advance
Badri
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Unless you send the input PeriodNum in text format and treat the transformation as text format you can't without in-built function. Can use Oconv or Format function to do this.

Thanks
Siva
mleroux
Participant
Posts: 81
Joined: Wed Jul 14, 2004 3:18 am
Location: Johannesburg, South Africa
Contact:

Post by mleroux »

Just check if it needs a leading zero:

Code: Select all

IF(LNK1.TRANSACTIONTYPE = '100' ) Then '1215' : (LNK1.Year - 1) 
Else 
  If LNK1.PeriodNum < 10 Then
    '0' : LNK1.PeriodNum : '15' : LNK2.Year
  Else
    LNK1.PeriodNum : '15' : LNK2.Year
Morney le Roux

There are only 10 kinds of people: Those who understand binary and those who don't.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As mentioned - format the output:

Code: Select all

IF(LNK1.TRANSACTIONTYPE = '100' ) Then '1215' : (LNK1.Year - 1) 
Else 
    FMT(LNK1.PeriodNum:'15':LNK2.Year,"8'0'R")
Note, the syntax is off the top of my head first thing in the morning, pre-coffee. It should be pretty darn close. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply