I have an order form that offers a discount if the order is placed prior to a certain date (ie. April 1).
What I am trying to do is have a number field populate with a price based on both the Current Date as well as the weight placed by the user.
User has 1,000 lbs
If they order ON or BEFORE April 1 - their price is $ 0.20 per lb
If they order AFTER April 1 - their price is $ 0.23 per lb
I am able to get this to work using the below form calc but ONLY if the user chooses the date. Obviously if someone is not playing fair they can choose an earlier date if they want to. (I have yet to find a way to prevent the Date field to be a past date).
I did try using the CURRENT DATE field but that did not work (the price per lb is not changing based on date).
I tried having the DATE field default to today's date and then make it Calculate but can't seem to get the date field to default to today's date.
Any ideas on how I can get this to work?
var changeDate = Date2Num( "2016-04-01", "YYYY-MM-DD" ) var expenseDate = Date2Num(DateTimeField1.rawValue, "YYYY-MM-DD" ) var expenseTest = expenseDate - changeDate if ( expenseTest < 0 and NumericField1 < 425 ) then $ = "Min" elseif ( expenseTest > 0 and NumericField1 < 370 ) then $ = "Min" elseif ( expenseTest < 0 and NumericField1 < 1000 ) then $ = "0.20" elseif ( expenseTest > 0 and NumericField1 < 1000 ) then $ = "0.23"
Note: Above is only an excerpt. Did not want to post entire code.