This is very simple in C3.
Use build-in Date Plugin #open=date-time
Example:
Date.ToTotalHours(Date.Difference(Date.Parse("2023-11-15"), Date.Parse("2023-11-20"))) / 24
If you also need to display localized currency units, then this will also be helpful to you #open=internationalization
---
OR You can use Javascript to calculate, Here is an example:
function calculateDaysDifference(userDate) {
const startDate = new Date('2023-11-15');
const endDate = new Date(userDate);
const diffInTime = endDate.getTime() - startDate.getTime();
const diffInDays = Math.floor(diffInTime / (1000 * 3600 * 24));
return diffInDays;
}
---
Example:
calculateDaysDifference('2023-11-20')
Output:
5
---
But if you are talking about C2, you may need to use Brower to execute JavaScript.