Date to char transformation

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
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Date to char transformation

Post by just4geeks »

Hi,

Input is YYYY-MM-DD
Column type is Date(10)

Output should be YYYYMDDD
Outout type is Char ( 8 )

How to remove '-' from input to get output in transformer or modify stage. I am trying to use string_from_date but it is not working.

Example: Input : 9999-12-31
outPut: 99991231

Thanks for help!
Attitude is everything....
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

You can use DateToString(In.Date,"%yyyy%mm%dd") change the sql type to char 8 in the output of transformer.
hi sam here
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Hi,

I used this function..

DateToString(DSLink3.DATE1)

I got following error:

Transformer_10,1: Internal Error: (length <= result.length()):date/conv.C: 562: Output string is not long enough to accomodate this format.
Traceback: msgAssertion__13APT_FatalPathFPCcRC11APT_UStringPCci() at 0xd3d806c0
convert__27APT_Conversion_UString_DateCFPCvPvT2() at 0xd36436f4
processInputRecord__65APT_TransformOperatorImplV0S10_test_date_to_string_Transformer_10Fi() at 0xd978e0c4
runLocally__22APT_CombinableOperatorFv() at 0xd376003c
run__15APT_OperatorRepFv() at 0xd36876a8
runLocally__14APT_OperatorSCFv() at 0xd3674054
runLocally__Q2_6APT_SC8OperatorFUi() at 0xd36f54ac
runLocally__Q2_6APT_IR7ProcessFv() at 0xd3771c68
executePlayer__18APT_ProcessManagerFP16APT_ScoreProcess() at 0xd3739d54
executeStep__FPC19APT_PMMessageHeader() at 0xd3806ed0

Can you tell me if the function syntax is correct. Date1 is input column with Date(10) type.

Thanks!
Attitude is everything....
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Did you give the conversion mask?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

Use DateToString(DSLink3.DATE1,"%yyyy%mm%dd") in your column derivation part , let the input be date (10) but in the output of transformer change it to char (8) .
Last edited by samsuf2002 on Fri Jun 08, 2007 7:51 am, edited 1 time in total.
hi sam here
rafik2k
Participant
Posts: 182
Joined: Wed Nov 23, 2005 1:36 am
Location: Sydney

Post by rafik2k »

Use convert or ereplace function in the transformer to remove "-" character from the input date like following

Code: Select all

Convert("-", "", DSLink3.DATE1) 
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Hi,

Whats mean by conversion mask!

Input is Date1, data type DATE(10)
output is of data type CHAR( 8 )

Thanks,
Attitude is everything....
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

"%yyyy%mm%dd" is the conversion mask/code. Did you use that with DateToString()? From your previous post, it does not look like you used it.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Hi DSguru,

U r right. I did not use it. Can u please tell me How can I use it.

I just used this : DateToString(DSLink3.DATE1)

Thanks!
Attitude is everything....
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

You used this ---> DateToString(DSLink3.DATE1)
Now use this ---> DateToString(DSLink3.DATE1,"%yyyy%mm%dd")
hi sam here
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Hi

I used the correct conversion mask code and it worked. also the the covert function also worked.

Earlier I tried with %yyyy-%mm-%dd% which was invalid.

Thanks all for help!!
Attitude is everything....
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

just4geeks wrote:Hi DSguru,

U r right. I did not use it. Can u please tell me How can I use it.

I just used this : DateToString(DSLink3.DATE1)

Thanks!
We haven't heard from U is a while, but I note that U is still a registered member.

The second person personal pronoun is spelled "you". The present tense plural form of the verb "to be" is spelled "are". Please take care to communicate professionally; it makes life easier for those posters (such as, one presumes, U from Burma) for whom English is not a first language.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
just4geeks
Premium Member
Premium Member
Posts: 644
Joined: Sat Aug 26, 2006 3:59 pm
Location: Mclean, VA

Post by just4geeks »

Hi All,

Iam extremely sorry if my unintended remarks are offensive to anyone. I did not mean them.

Warm regards,
Attitude is everything....
Post Reply