Validating Expiration Date, Modify Field

bnkjamesbnkjames Member Posts: 6
I'm trying to write a function that validates the expiration date and compares it to today's date.
Then if today's date is passed the expiration date, flips a flag to mark it expired.
Here's what I have so far.
Credit Card Expiration Date(OnValidate)

D := TODAY;
Day := DATE2DMY(D,1);
Month := DATE2DMY(D,2);
Year := DATE2DMY(D,3);

IF (Text001) > "Credit Card Expiration Date" THEN BEGIN
Expired := TRUE
Modify(TRUE);
END;

Text001 = %2/%3

I realized it was trying to divide these values, so I'm not sure how to calculate this.

Comments

  • matttraxmatttrax Member Posts: 2,309
    Assuming Credit Card Expiration Date is an actual Date field, there is no need for all of this:
    bnkjames wrote:
    D := TODAY;
    Day := DATE2DMY(D,1);
    Month := DATE2DMY(D,2);
    Year := DATE2DMY(D,3);

    Just do:
    IF TODAY > "Credit Card Expiration Date" THEN BEGIN
      Expired := TRUE;
      MODIFY;
    END
    

    If however it is a text field, only containing the month and year then you are on the right track. Use some code to separate out the month and year from Credit Card Expiration Date (Hint: STRPOS to find the separator, and COPYSTR to get the substring). Now you have two months and two years to compare with each other. Don't forget that you may have to account for instances where the date was put in as both 11 and 2011 for example, and the month as 01 and 1.
  • bnkjamesbnkjames Member Posts: 6
    Thanks for the advice!
    I think we may go a different route with this, but I've jotted this down.
Sign In or Register to comment.