Validating Expiration Date, Modify Field

bnkjames
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.
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.
0
Comments
-
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.0 -
Thanks for the advice!
I think we may go a different route with this, but I've jotted this down.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions