Convert string to a number

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
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Convert string to a number

Post by Marley777 »

Thanks for reading. How can I convert an input field from varchar 255 to an integer. The fields are latitude and longitude.

below is the value in the longitude field
-84.469345

below is the value in the latitude field
39.074253

Both values come in as varchar 255, but need to convert to integer and keep the '-' sign.

Any help is grealy appreciated.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What have you tried? Isn't this just a simple StringToDecimal() conversion?
-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 »

StringToInteger giver me everything before the decimal position. I'm loading to a db2 field defined as integer...so string to decimal won't work. So not sure how to convert to integer and keep everything to the right of the decimal?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry, missed the "integer" part. You... can't. Ask them what "-84.469345" should be as an integer and then you'll know how to handle the conversion. My guess? "-84469345".
-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 »

how can I keep the numbers to the right of the decimal?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As shown above. Keep in mind the fact that, in an integer, there is no "right side of the decimal".
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Multiply by 100000.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... the end result of which was shown as "my guess" above.
-craig

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