Midrange News for the IBM i Community


Posted by: renojim
concat with leading zero's
has no ratings.
Published: 11 Feb 2014
Revised: 11 Feb 2014 - 1765 days ago
Last viewed on: 11 Dec 2018 (3025 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

concat with leading zero's Published by: renojim on 11 Feb 2014 view comments(3)

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: concat with leading zero's
Posted: 4 years 10 months 2 hours 27 minutes ago

DIGITS function will do it.

SELECT CONCAT(DIGITS(firstfield), DIGITS(secondfield))

It uses absolute value of the number, so if your values can ever be negative, you'll want some sort of CASE to deal with the sign.

Posted by: tdaly
Premium member *
Comment on: concat with leading zero's
Posted: 4 years 10 months 2 hours 12 minutes ago
select ((fld1 * 10000) + fld2) as myfld
Posted by: renojim
Premium member *
Comment on: concat with leading zero's
Posted: 4 years 10 months 2 hours 1 minutes ago

Excellent!! Thanks.