function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vrushali Pradhan 10Vrushali Pradhan 10 

compare dates in javascript on a custom button

I am trying to compare dates  to allow the clone functionality to work. I have following javascript on a custom button but it doesnt work.
var SCAssgn = "{!Quote__c.CreatedDate}"; 
var mydate = new Date(SCAssgn); 
var cutoff = new Date("10/6/2017") 
alert(cutoff) ; 
if(SCAssgn < cutoff ) 

alert("You cannot clone this quote. Please create a new Quote"); 

else { 
Malni Chandrasekaran 2Malni Chandrasekaran 2

Please try,
if (SCAssgn.getTime() > cutoff.getTime())

We cannot compare the date object directly.
hope this helps!
Deepak Pandey 13Deepak Pandey 13
I think it will help.