I am trying to write a date compare function to see if the stored Data is up to date with what i am trying to import. To do so i need to compare my stored Sales date with the Date provided in a csv file. My stored Sales Date is in a the following format 2007-03-06T00:00:00.000Z and the date in my csv is 05/10/2019 I know i can try to extrct date from the jsonString but i am hoping there is a function which will allow me to do a simple compare. Below is a simple slice i used to make it work but there should be a better way
date1 = "2019-05-10T00:00:00.000Z"
date2 = "05/10/2019"
newDate = date1.slice(5,7) +"/" + date1.slice(8,10) +"/" + date1.slice(0,4)
console.log(newDate)
if (newDate != date2){
console.log("dates dont match")
}
else {
console.log("We have latest sale")
}