• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

extracting iso date field from form

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

  • extracting iso date field from form

    I have 2 fields on a form SHPDT_ISO and CANDT_ISO both defined as date fields. How do I extract them from the form and converted the to an 8,0 date field. I have the field datefld8 defined as a date field in the program but I am getting an error when trying to compile. I tried using GetFormChar as well.


    datefld8 s d datfmt(*iso)

    datefld8 = GetFormNum('SHPDT_ISO');
    uiso = datefld8;
    thsdte = uiso;
    datefld8 = GetFormNum('CANDT_ISO');
    uiso = datefld8;
    thcdte = uiso;


    *RNF7416 30 017148 The types of the right and left hand side do not match in
    the EVAL operation.
    *RNF7416 30 017150 The types of the right and left hand side do not match in
    the EVAL operation.
    *RNF7416 30 017152 The types of the right and left hand side do not match in
    the EVAL operation.
    *RNF7416 30 017154 The types of the right and left hand side do not match in
    the EVAL operation.


  • #2
    To pull in a date value you'd need to use GetFormChar('SHPDT_ISO'), since from the browser's perspective a date field is a character field. Then wrap it in %date().

    Also, to avoid confusion, you might want to give your work field a different name -- i.e., dateFld_iso instead of dateFld8.

    So it'd become this:
    Code:
    dateFld_iso = %date(getFormChar('SHPDT_ISO'));

    And if your program subsequently needs to convert from an ISO date to an 8-digit numeric (meaning 'YYYY-MM-DD' to YYYYMMDD), you could do something like this:
    Code:
    if dateFld_iso <> d'0001-01-01';
      dateFld8 = %int(%char(dateFid_iso:*iso0));
    else;
      dateFld8 = 0;
    endif;
    Last edited by robert.swanson; 06-14-2021, 02:28 PM.

    Comment


    • #3
      awesome thank you !

      Comment

      Working...
      X