decimal issue

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
chrisjones
Participant
Posts: 194
Joined: Thu May 11, 2006 9:42 am

decimal issue

Post by chrisjones »

Hi ,
i am getting amounts as 1045000, 8982..etc but i need to load as
10450.00, 89.82..ect..can you help me how to get this done in datastage
Thanks,
Chris Jones
chrisjones
Participant
Posts: 194
Joined: Thu May 11, 2006 9:42 am

Post by chrisjones »

amount col in source is varchar(12) and target is decimal is (10,2), so i used the below string to decimal function but no getting the required output..data is getting loaded same as source wihout 2 decimals

If Trim(NullToValue(match_pymt_id.PROJECTED_SPEND,'0')) = '0' then 0
Else if trim(match_pymt_id.PROJECTED_SPEND)='' then '0' else StringToDecimal((TrimLeadingTrailing(match_pymt_id.PROJECTED_SPEND)))
Thanks,
Chris Jones
chrisjones
Participant
Posts: 194
Joined: Thu May 11, 2006 9:42 am

Post by chrisjones »

or

can i do like this, get the amount except last 2 digits concatinate with '.' and then get get the last 2 digits.

ex 8986 =89'.'86 => 89.86

if the above thing works , can someone tell me how to get the amount except the last two digits and also how to get just the last two digits since the source amount length keeps on changing
Thanks,
Chris Jones
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Import the string as-is into a decimal and then divide by 100.

StringToDecimal(field)/100
- james wiles


All generalizations are false, including this one - Mark Twain.
rahcomp
Participant
Posts: 11
Joined: Wed Apr 18, 2012 2:13 pm

Re: decimal issue

Post by rahcomp »

You may try DecimalToDecimal() In the stage variables and assign the variable value to the column
Rahul
DS Lover
rahcomp
Participant
Posts: 11
Joined: Wed Apr 18, 2012 2:13 pm

Re: decimal issue

Post by rahcomp »

In fact try assigning your string value to a decimal type stage variable....
Datastage would implicitly handle it.
Rahul
DS Lover
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

He would still need to explicitly handle the position of the decimal point. Implicitly, 5948 would become 5948.00 without further logic.
- james wiles


All generalizations are false, including this one - Mark Twain.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This.
jwiles wrote:Import the string as-is into a decimal and then divide by 100.

StringToDecimal(field)/100
-craig

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