Date is printed as a decimal value in custom button

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:

enter image description here


1 Answer 1


Please 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.

Not the answer you're looking for? Browse other questions tagged .