I am trying to compare dates in custom button which executes JavaScript when clicked. The date values are printed as decimal value which makes it difficult to compare. Any suggestions whats happening here ?
The output is as below:
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityPlease enclose your date variables with quotes as below.
var milestoneDueDate = new Date('{!Milestone__c.Current_due_Date__c}');
var toDay = new Date('{!TODAY()}');
With this approach it will create date variables with given string value.
At the moment, your date format may be dd/mm/yyyy
. Then if you have the date as 06/10/2022, then it will be evaluated to 6 devided by 10 devided by 2022. That is why you end up with having a decimal value.