Page 1 of 1
Small Integer to Date
Posted: Wed Nov 10, 2004 12:19 pm
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!
Posted: Wed Nov 10, 2004 2:08 pm
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.
Posted: Thu Nov 11, 2004 3:36 pm
by Marley777
in your example
Fmt(YR,"R%4") : "-" : Fmt(MO,"R%2") : "-" : Fmt(DA, "R%2")
What does 'R' represent.
Thanks
Posted: Thu Nov 11, 2004 3:50 pm
by chucksmith
Right justified.
Posted: Thu Nov 11, 2004 3:58 pm
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".
Posted: Thu Nov 11, 2004 6:26 pm
by Marley777
Posted: Thu Nov 11, 2004 6:43 pm
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.
![Confused :?](./images/smilies/icon_confused.gif)
Posted: Thu Nov 11, 2004 8:24 pm
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.
Posted: Thu Nov 11, 2004 9:33 pm
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.