ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Data Conversion from Char to Numeric in WRKQRY

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Data Conversion from Char to Numeric in WRKQRY

    hello,

    In AS/400 query how do you change an alpha field into a numeric to do math on it?



    Example: VARIABLE is defined as an alpha field 4 characters long and has the value ?1234? in it.

    I want to add VARIABLE and the field SCORE together to get a sum, what command do I use in query to redefine VARIABLE

    as a numeric field?


    regards,
    Anil.

  • #2
    Re: Data Conversion from Char to Numeric in WRKQRY

    medam.anil,

    I believe DIGITS(NumericField) will do the trick.

    HTH,
    MdnghtPgmr
    "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

    Comment


    • #3
      Re: Data Conversion from Char to Numeric in WRKQRY

      I believe this will convert Numeric to Character, but not Vice-versa.

      Anil.

      Comment


      • #4
        Re: Data Conversion from Char to Numeric in WRKQRY

        Hi medam.anil:

        There is only a limited way of converting alpha to numeric within query/400. This involves convrting the alpha field to the microsecond portion of a time stamp.



        Because it is so convoluted and down outright bizzar I avoid it as much as is humanly possible.

        Use another high level language or create some dds in qtemp and copy the file with nocheck is what I would recomend.

        Best of Luck
        GLS
        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

        Comment


        • #5
          Re: Data Conversion from Char to Numeric in WRKQRY

          Thanks for this info.

          Comment

          Working...
          X