Hi everyone. I've browsed these forums for months and found a lot of great answers to every question I've had so far... except one. And I've searched this and other forums, Google and everywhere else I could think of and I still have not found the answer.
I'm working on an order form with various quantities, pricing and other charges involved. There is one field that will not work no matter what I do. It is a discount field that should be applied based on whether or not the current date is past a specified cut-off date.
First, I have two date fields. One ("ModDate") is calculated as the modification date of the document with this code in the custom calculation script:
event.value = util.printd("dddd mmmm d, yyyy h:MM tt", info.ModDate);
The second date field ("DiscountEnds") is the cut-off date for the discount and is entered manually.
And finally I have a field that should be calculating either a 25% discount if the current ModDate is before the deadline or o% discount if the current ModDate is after the deadline.
The most recent JavaScript I used was this:
event.value = 0; // Initial discount value
var date1 = this.getField("ModDate").value;
var date2 = this.getField("DiscountEnds").value;
var disc = this.getField("EqTotal").value;
if(date1 < date2)
event.value = disc * (-.25);
Prior to that, I had some limited success with this script:
if (this.getField("ModDate").value > this.getField("DiscountEnds").value) event.value = this.getField("EqTotal").value * (-.25);
else event.value = 0;
This script actually calculated the discount, but it was random when it would apply it. It was not based on a comparison of the two dates as far as I could tell.
I'm wondering if I need to convert the two dates to a time or a number for comparison... but I can't figure out how to do that.
Note: Using Acrobat Pro 10.1.0 on OS X
Thanks in advance!