You need to sign in to do that
Don't have an account?
Vrushali 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);
alert(mydate);
var cutoff = new Date("10/6/2017")
alert(cutoff) ;
if(SCAssgn < cutoff )
{
alert("You cannot clone this quote. Please create a new Quote");
}
else {
cloneQuote();
}
var SCAssgn = "{!Quote__c.CreatedDate}";
var mydate = new Date(SCAssgn);
alert(mydate);
var cutoff = new Date("10/6/2017")
alert(cutoff) ;
if(SCAssgn < cutoff )
{
alert("You cannot clone this quote. Please create a new Quote");
}
else {
cloneQuote();
}
Please try,
if (SCAssgn.getTime() > cutoff.getTime())
We cannot compare the date object directly.
hope this helps!
I think it will help.