ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Remove slashes from date

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

  • Remove slashes from date

    Date conversions drive me crazy.
    How do I remove the slashes from the 'b_char_8' and 'e_char_8' fields below?
    Code:
    *----------------------------------------------------------
    *
    * Determine First and Last dates.
    *
    start_date = %date(%subst(%char(%date(mydate)):1:8) + '01':*ISO);
    end_date = start_date + %months(1) - %days(1);
    *----------------------------------------------------------
    *
    * Convert dates to character.
    *
    b_char_8 = %char(start_date:*mdy/);
    e_char_8 = %char(end_date:*mdy/);
    *----------------------------------------------------------
    I tried the obvious but it didn't work.
    Everyday's a school day, what grade are you in?

  • #2
    You can use *MDY0 (zero at the end)

    b_char_8 = %char(start_date:*mdy0);
    e_char_8 = %char(end_date :*mdy0);

    Comment


    • jtaylor___
      jtaylor___ commented
      Editing a comment
      The "0" at the end of a date/time format code removes the separators. This works for to/from a character field.

    • JonBoy
      JonBoy commented
      Editing a comment
      It also controls whether they are expected to be present when going the other way - i.e. %Date etc.

      RPG assumes that if the source or target field in a date conversion is character then it will have separators. You have to use the "0" separator to say that there isn't one.
Working...
X