Small Integer to Date

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
RSchibi
Participant
Posts: 8
Joined: Mon Apr 19, 2004 6:13 am

Small Integer to Date

Post by RSchibi »

I am trying to concatenate smallInt MO,DAY & YR into a date field.
The MO & DAY are 2 bytes & YR is 4. The date field will be
yyyy-mm-dd format (type DATE).

The code I'm using is YR:"-":MO:"-":DA

This works if the MO & DA are > 9 (no leading zeros)

MO = 10 DAY=15 YR = 2004 gives 2004-10-15

MO = 03 DAY=05 YR =2004 gives '**********'

This records will not load into a DB2 table because of the '*'s in a date field.

Thanks for any help you can give!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's a BASIC expression. A suitable BASIC expression would be

Code: Select all

 Fmt(YR,"R%4") : "-" : Fmt(MO,"R%2") : "-" : Fmt(DA, "R%2")
Apparently (according to other posts on this forum), you should seek to use a non-BASIC expression if you're truly working in the PX environment.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

in your example

Fmt(YR,"R%4") : "-" : Fmt(MO,"R%2") : "-" : Fmt(DA, "R%2")

What does 'R' represent.

:oops: :oops: :oops: :oops:


Thanks
chucksmith
Premium Member
Premium Member
Posts: 385
Joined: Wed Jun 16, 2004 12:43 pm
Location: Virginia, USA
Contact:

Post by chucksmith »

Right justified.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

And the "%" means add leading zeroes as a mask.

Another way to write this would be to use zero as a background character.

Code: Select all

Fmt(YR,"2'0'R") : "-" : Fmt(MO,"2'0'R") : "-" : Fmt(DA, "2'0'R") 
The zero has to be quoted to differentiate between "width of 2 with a background character of '0'" and "width of 20".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

People tell me that Datastage uses BASIC code. What is the difference between BASIC, C, and C++? I'm currently teaching myself C/C++, but not sure If it will help me as far as Datastage is concerned. Are they all the same thing? What is the difference?


Thanks for your time, input and patience.


:? :? :? :?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Without going into tons of detail right now - DataStage Server Edition 'uses' BASIC, DataStage Enterprise Edition (EE/PX) 'uses' C++ as its foundational language.
RStone wrote:Are they all the same thing?
Yes, in the sense that they are all programming languages.
RStone also wrote:What is the difference?
They are different programming languages, with different capabilities and degrees of difficulty to learn and to not hurt yourself in the process.

Not to be a smarty-pants or anything, but these are kind of scary questions. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

I understand why you think these questions are scary. I asked them in a way that would lead
Someone to believe I know nothing about programming (my mistake). I am very familiar with B, C, and C++ and how one is an expansion or progression on the other all the way into JAVA. I know they are programming languages, but I never use them so syntactically I'm weak with these languages. I come from a COBOL and Visual Basic Background. I simply wanted to ask veterans like you if the C language is very similar to the BASIC language (some say they are different). If they are not I will not waist my time learning C languages. I will instead focus on the BASIC language using the Datastage manuals. I assume they are the same because DS does in fact use the C++ compiler. With this said, what manuals would you focus on if you were me. Sorry about this book.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you're going to do a lot of work in PX do take the trouble to learn C or C++. They are radically different languages from DataStage BASIC; for a start, the C languages are very strict about data types and variable declaration; BASIC doesn't get concerned about either. BASIC does not use pointers; everything is passed "by reference" (a simplification, but you get the idea I trust). BASIC has no concept of variable scope.

They have made it possible to use BASIC expressions in PX, probably with some reluctance. There is a definite performance penalty.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply