Search code examples
daterpgle

How to TEST(D) DATE if have format yyyy/mm/dd in RPGLE?


How to test char date in format yyyy/mm/dd ?

I try to use :

*YMD      TEST(D)       DATE            80

I want to test this 2021/15/30 date because I want to make sure the date is validated but seems like it doesn't work even if I test the right Date like 2021/06/01. What should I do?

I also try this :

          Eval    DT = %CHAR(%DATE(DATE:*YMD/))    
*YMD      TEST(DE)       DT           
          IF NOT %ERROR()

          Move    DT      DATE
          Write   Currec

          Endif

I enter 2021/06/01 as input but got this error instead :

error

What should I do?


Solution

  • RPG doesn't support the YYYY/MM/DD format. You can use %XLATE to change the / to - and then use the *ISO format.

              EVAL    DATE = %XLATE('/' : '-' : DATE)
    *ISO      TEST(DE)       DATE