ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Check for blank dates

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

  • #16
    Re: Check for blank dates

    A quick fix would be to just add a monitor around the if statement.

    Code:
    MONITOR;
      S2ASGDT = ISASGDT;    
    ON-ERROR *ALL;
      S2ASGDT = *LOVAL;
    ENDMON;
    Your database date is probably defined as an *ISO, which has a loval of 0001-01-01 and a hival of 9999-12-31.
    The MDY field from the screen has a loval of 01/01/40 and a hival of 12/31/39.

    So this statement probably won't work because ISTARDT is d'0001-01-01';
    Code:
    IF ISTARDT = d'01/01/40';
       S2ASGDT = d'01/01/40';
    ELSE;                    
       S2ASGDT = ISASGDT;    
    ENDIF;
    Here is another alternative that doesn't involve the Monitor.

    Code:
    D DATE_MDY S D DATFMT(*MDY)
    Code:
    DATE_MDY = *LOVAL;
    IF ISTARDT < DATE_MDY;
      S2ASGDT = *LOVAL;
    ELSE;  
      DATE_MDY = *HIVAL;
      IF ISTARDT > DATE_MDY;
        S2ASGDT = *HIVAL;
      ELSE;
        S2ASGDT = ISTARDT;
      ENDIF;
    ENDIF;

    Comment

    Working...
    X