Query 400 Characters to Digits

15 pts.
Tags:
Query for OS/400
How to convert numbers saved as characters into digits.

Is there any Query instruction to convert Characters into Digits?  I'm trying to link 2 files, and one of the fields is character in one file and digits in the other, so I can't link them.  For example:   00877874 is saved as character in file 1 and is saved as digits in file 2.  Thanks for the help.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I didn’t see any built-in function to convert characters to digits. However, the DIGITS() function can convert numerics to characters. Although it’s not in the direction that you wanted, perhaps it can be used in a similar way.

Tom

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
    Tom's right but there is a bit of a workaround http://webcache.googleusercontent.com/search?q=cache:cqvppvzC34IJ:i-seriesusergroup.org/2006/04/18/tip-converting-string-to-number-in-query400/+query+400+convert+character+to+numeric&cd=3&hl=en&ct=clnk&gl=us These two result fields take a six digit string named fldString and convert it to a 6 0 numeric. tStamp TIMESTAMP(’1995-01-01-12.00.00.00′||fldString) fldNumeric MICROSECOND(TIMESTAMP) Phil
    49,590 pointsBadges:
    report
  • philpl1jb
    Sorry, that was for 4 digits -- there is for 6 tStamp TIMESTAMP(’1995-01-01-12.00.00.′||fldString) fldNumeric MICROSECOND(TIMESTAMP) Phiil
    49,590 pointsBadges:
    report
  • Aumar
    Thank you Tom & Phil. I found another solution which is using a CPYF with *NOCHECK to move it from CHAR to numeric. That would be an extra step in the process. I'll try Phil's solution also. THANK YOU!
    15 pointsBadges:
    report
  • TomLiotta
    Ah, yes. The old "pretend it's a Timestamp" routine. I definitely forgot that one. As always, I would simply recommend not using Query/400 at all and creating a QM query instead. Either a CAST() specification or a ZONED() function can make the conversion explicit and more understandable for future maintenance. But Phil's right. This can be used if necessary. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following