ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Issue in Date Conversion

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

  • Issue in Date Conversion

    Hello All,

    I have a Numeric Field of length 8 and dec position as 0. A date Field which I have initialized to '1900-01-01'. Now I am trying to move the value in the Date field to the Numeric field in Free Format RPGLE. This is the below statement.

    Eval Cdate = %Dec(%Char(Cdate1:*ISO-):8:0);

    This I got from one of the sites. But this statement gives a Runtime Error : "A character representation of a numeric value is in error."

    Tried many permutations and combinations but all in vain.

    Can somebody assist ?

    Thanks and Regards
    Mukund G Kallapur

  • #2
    Re: Issue in Date Conversion

    The problem is you are converting the date field to character and inserting - characters into the result. Since - characters are not valid in a decimal field, you get an error. This can be fixed by removing the date separators when you convert to character:
    Code:
    Eval Cdate = %Dec(%Char(CDate1:*ISO0): 8: 0);
    However... it is not necessary to convert the date to character, unless you are on a VERY old release (V5R2, I think) So please do it the easier way, and just do this:

    Code:
    Eval Cdate = %Dec(CDate1: *ISO);

    Comment


    • #3
      Re: Issue in Date Conversion

      Thank you very much Scott.....Finally got it

      Comment

      Working...
      X