Hello,
I am using LiveCycle Designer 8.05 and I am trying to create a field where users enter a effective date ("txt_effdate" - a 'Date/Time' field) and an end date ("txt_enddate" - also a 'Date/Time field) for a transaction, and if the end date is less than six months from the start date they get an error message.
I successfully used the code below to read the "txt_effdate" field and create another field ("sixmos") that displays a date six months after the start date:
// "sixmos" - text field
var effDate = util.scand("mm/dd/yyyy", txt_effdate.formattedValue);
var sFullYear = effDate.getFullYear();
var sMonth = effDate.getMonth();
var sDate = effDate.getDate();
this.formattedvalue = util.printd("mm/dd/yyyy", new Date(sFullYear, (sMonth + 6), sDate) );
The trouble comes in when I try to compare the end date to the "sixmos" date. The following code lets all dates pass, meaning it cannot recognize that the "txt_enddate" is less than the "sixmos" date:
var aeffdate = util.scand("mm/dd/yyyy", txt_effdate.formattedValue);
if (aeffdate < sixmos.rawValue) {
xfa.host.messageBox("End Date is less than 6 months from Start Date, please make correction.", "End Date Issue");
}
I've tried comparing "txt_effdate" directly to "sixmos", with various uses of rawValue and formattedValue extensions. I've also tried aeffdate.value instead of just aeffdate... am I missing something simple here?
Thanks for the help!