ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

substring

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

  • substring

    Dear all
    In my display file the format of the date field is dd/mm/yyyy. Display file having "From "date field and "to" date field . for this range of year should be same . how to vslidate this .?
    example


    if i give 03/12/2005 to 31/01/2006 it should throw the error .


    if it is string means i can do substring but this numeric that's y any one can help for this validation?

    with regards
    sudha
    The Secret Of Achieving Your Goals Is Revealed Before Your Eyes.
    System Engineer

    Sudha...

  • #2
    Re: substring

    something like this just change month to year and *CYMD to *USA
    then say if years > 1 = ERROR!!!!!


    PHP Code:
    d CYMD1           S              7  0 inz(1050101)                  
    d CYMD2           S              7  0 inz(1060201)                  
    d somefield       S              4  0                               
     
    *=============================================================     
     *  
    M A I N     L I N E                                             
     
    *=============================================================     
    c                   if        %diff(%Date(CYMD1:*CYMD):             
    c                                   %Date(CYMD2:*CYMD):             
    c                                   *months)  >= 12                 
    c                   
    eval      somefield +=1                         
    c                   
    endif                                           
     *                                                                  
    c                   Eval      *Inlr = *On                           
    c                   
    Return 
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: substring

      --or-- if %subdt(somedate:*Year) <> %subdt(someotherdate:*year)
      BIG O ERROR
      endif
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: substring

        If the fields are numeric, you could do

        IF %subdt(%date(Fromdate:*MDY):*Y) <> %subdt(%date(Todate:*MDY):*Y)

        However this will throw an error if Fromdate ot ToDate are invalid entires

        Comment

        Working...
        X