Small Integer to Date
Moderators: chulett, rschirm, roy
Small Integer to Date
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!
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!
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That's a BASIC expression. A suitable BASIC expression would be
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.
Code: Select all
Fmt(YR,"R%4") : "-" : Fmt(MO,"R%2") : "-" : Fmt(DA, "R%2")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 385
- Joined: Wed Jun 16, 2004 12:43 pm
- Location: Virginia, USA
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
And the "%" means add leading zeroes as a mask.
Another way to write this would be to use zero as a background character.
The zero has to be quoted to differentiate between "width of 2 with a background character of '0'" and "width of 20".
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")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Without going into tons of detail right now - DataStage Server Edition 'uses' BASIC, DataStage Enterprise Edition (EE/PX) 'uses' C++ as its foundational language.
Not to be a smarty-pants or anything, but these are kind of scary questions.
Yes, in the sense that they are all programming languages.RStone wrote:Are they all the same thing?
They are different programming languages, with different capabilities and degrees of difficulty to learn and to not hurt yourself in the process.RStone also wrote:What is the difference?
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
"You can never have too many knives" -- Logan Nine Fingers
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.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.