title: JMeter BSF Assertion - comparing date variables
body: <p>I am attempting a BSF Assertion using javascript in JMeter.</p>
  
  <p>In the JMeter Debug Sampler I have these two variables: 
  insert_date=2013-11-11 16:22:33.000343
  db_created_date_1=2013-11-11 16:22:53.863187</p>
  
  <p>and I want to compare them to see if they occurred within a specific time range of plus or minus 10 seconds of each other - 
  or if the time difference is more than 20 seconds. </p>
  
  <p>What is the best way to do this? </p>
  
  <p>I don't know if I should use the Date.parse(dateVal) 
  The Date.parse function returns an integer value representing the number of milliseconds between midnight, January 1, 1970 and the date supplied in dateVal. </p>
  
  <p>I have been trying this with a BSF Assertion - javascript,  but it is not working:</p>
  
  <pre><code>if ((vars.put("my1",Date.parse(vars.get("db_created_date_1"))) - vars.put("my2",vars.get("insert_date")))  != 0) {
      AssertionResult.setFailure(true); 
      AssertionResult.setFailureMessage("ERROR: The difference between db_created_date value (${db_created_date_1}) ${my1} and the dateTime (${insert_date}) ${my2} is too great.");
  }
  </code></pre>
  
  <p>The Assertion result: 
  Assertion error: false
  Assertion failure: true
  Assertion failure message: ERROR: The difference between db_created_date value (2013-11-11 16:22:53.863187) NaN and the dateTime (2013-11-11 16:22:53.863187) NaN is too great.</p>