Date change issue with function. HELP!

Date change issue with function. HELP!

Hi all,

I am having an issues that I want a date field to automatically update to be 5 days before another date field that I have created but although in the deluge console it is coming out as the correct date when I run the function all it does is copy the other field and not amend it to 5 days before. Also all of the fields flash to show they have been updated which is strange.

I have a hunch it is something to do with formatting but stuck at this point. Will attached images to help and the deluge code below:

// Retrieve the record details
record = zoho.crm.getRecordById("Potentials",record_id);
// Calculate the updated date by subtracting 5 days
updatedDate = record.get("When_Needed").toDate();
info updatedDate.subDay(5);
// Update the 'Order_By_Date' field with the updated date
record.put("Order_By_Date",updatedDate);
// Save the record
response = zoho.crm.updateRecord("Potentials",record_id,record);

Thank you