Subtracting Dates

I have 2 variables, one is start time and the other is stoptime. I want to subtract starttime from stoptime to get total time in hours, minutes or seconds. What I’m currently doing is first converting them to number and then subtracting (var1.value.toNumber-var2.value.toNumber) but it’s not working. Kindly suggest some solution.

Are you hand-coding or using the data picker?
'toNumber' should be '.toNumber()'

What exactly is your goal? Why converting the dates to numbers, when there are formatters available for calculating dates difference.

Data picker. In above message I didn’t copy it from the actual code that’s why .toNumber is written instead of .toNumber()

I want to calculate travel cost which is equal to [(stoptime-starttime)*travelfee/hr]. At start I put current time in var1 and at end I put current time in var2. Let’s suppose starttime= 21-07-2020 09:45:00 and stoptime= 21-07-2020 10:30:00, I want to calculate its difference which is 0.75 hours.

I haven’t found the formatters for it as I’m new to wappler, Can you please mention where can I find the formatter for calculating the difference.

Thankyou @Teodor, I found the way to do this, using formatter secondsUntil.
var_difference=var_starttime.secondsUntil(var_stoptime)

2 Likes