Trying to calculate days since Stage changed

Trying to calculate days since Stage changed

Hello, trying to calculate days since stage changed so we can display on Listview and Kanban. This is for the Deals module, which we renamed to Jobs.

I first made an automation rule that edited a "Current Stage Date" field anytime we changed stage. That is great on listview and Kanban, but what would be even better is # of days since then.

Here is my function:

// Get the current Job's details
JobInfo = zoho.crm.getRecordById("Jobs",JobId);
stageChangeDate = JobInfo.get("Current_Stage_Date");
info stageChangeDate;
if(stageChangeDate != null)
{
// Get the current stage date & today
currentDate = today;
info currentDate;
// Calculate the number of days between the current date and the stage change date
daysInStage = stageChangeDate.toDate().daysBetween(currentDate.toDate());
//daysInStage = daysBetween(stageChangeDate,currentDate);
// Update the custom field with the calculated number of days
updateMap = Map();
updateMap.put("Days_in_Stage",daysInStage);
updateResponse = zoho.crm.updateRecord("Jobs",JobId,updateMap);
}

Any help would be appreciated!