0

Need to set a numeric field (Late Fee) if the Current Date is past a set date (3/31/17). I have a Date/Time field setup to at "form ready" to display the Current Date. To test in Preview mode, I was using the set date as 1/1/17. This is for a recreational softball registration form. If the user prints the form after 3/31/17, then the Late Fee of $10.00 will auto-populate in the Numeric Field, LateFeeCalc.

My JavaScript set on the numeric field on the initialize event (because the date is set to current date when form is opened). There is no calculation involved.

if (Date2Num(SubFormCommands.MasterPage.PAGE2.RegistrationForm.Details.CurrentDate.formatted Value, "MM/DD/YYYY") > Date2Num("01/01/2017", "MM/DD/YYYY") then $=10

I have tried to tweak this several ways and received a variety of syntax errors surrounding the then portion of the statement. I have replaced the "then" with brackets but no change. I have tried to set variables, but no change. When I rarely received no syntax error message, the functionality simply didn't work.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • http://https//1drv.ms/b/s!AukslpvW9eo8gRbZGnkZJ3pIdGgR – lauras017283 Jan 16 '17 at 18:56
  • ^ Your link above breaks for me, and file lockers are not an appropriate way to share code anyway. If readers need to see more of your work, please put it in the question, and not on an external website. – halfer Jan 17 '17 at 20:59

2 Answers2

0

Use the Date() function like so

var end = new Date('2017', '03', '31').getTime() / 1000;
var now = new Date().getTime() / 1000;

console.log( now > end ) // false

Example: https://repl.it/FKhe

Also, duplicate? Compare two dates with JavaScript

Community
  • 1
  • 1
Baruch
  • 2,381
  • 1
  • 17
  • 29
0

In this case i would like to simplify things.

    var lastDate=new Date("3/31/17");
    var currentDate=new Date();
    //Empty param takes current date

    //Now you can Compare these dates 
    if(currentDate>lastDate){
        //Charge $10 fine
    }else{
        //Charge regular fee
    }
Ajaz
  • 93
  • 1
  • 1
  • 14