Convert Date String to Object and Compare Two Dates

I’m trying to pull in a date string (e.g. 8/27/20) soldDate that is pulled from a webpage via storeText. Then I want to compare this date to another date.

Basically I want to do action ABC if soldDate happened within the past six months and action XYZ if it happened longer than six months ago.

I’ve tried many different things to no avail.

function whenSold() {
  var sixMO = new Date(new Date().getTime() + 24 * 60 * 60 * 1000 * (-180));
  var soldDate = "${soldDate}";
  var d = new SimpleDateFormat("MM/dd/yyyy").parse(soldDate)
  
  sixMO > d,
}

I tried repurposing this post but it didn’t work for me: Date change with if/else statement

It looks like I can get the date six months ago. My two questions are, 1.) how do I format a date like ‘8/27/20’ as a date object so that I can compare it to the first date in javascript, and 2.) is sixMO > d the correct expression to return a boolean true or false that I can base the other steps in the macro upon?

Any help is appreciated.

I figured it out:

        {
  "Name": "dates-1",
  "CreationDate": "2020-10-16",
  "Commands": [
    {
      "Command": "store",
      "Target": "8/6/2020",
      "Value": "soldDate"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var sixMA = new Date(new Date().getTime() + 24 * 60 * 60 * 1000 * -180);\n\nvar parts = ${soldDate}.split('/');\n// Please pay attention to the month (parts[1]); JavaScript counts months from 0:\n// January - 0, February - 1, etc.\nvar soldDate = new Date(parts[2], parts[0] - 1, parts[1]);\n\nreturn sixMA > soldDate",
      "Value": "var1"
    }
  ]
}

javascript portion:
var sixMA = new Date(new Date().getTime() + 24 * 60 * 60 * 1000 * -180);
var parts = ${soldDate}.split('/');
// Please pay attention to the month (parts[1]); JavaScript counts months from 0:
// January - 0, February - 1, etc.
var soldDate = new Date(parts[2], parts[0] - 1, parts[1]);
return sixMA > soldDate