The summary/calculation function below rows is a great opportunity for calculating average response or closing times in tickets!
But I have problems calculating the ticket closing time with the function “=@closed at-@created at” - both are dates and times, logically the formula should respond with either seconds, minutes or else - but none of these make sense.
E.g. Ticket has been created on Fri, 2023-08-25 at 1:15 pm and closed within 15 seconds (Automation writes “closed” time stamp in specific field) the calculation gives me “11706”. This can neither be seconds nor milliseconds. Can anyone explain the unit when substracting two dates?
Hi @joschkalang,
what an amazing use case for the Tape calculation field! Of course you should be able to choose which unit your time delta is composed of.
You can use Tape’s powerful built in libraries to perform most date calculations you need.
For example:
// yields the difference in minutes
date_fns.differenceInMinutes(new Date(@date1), new Date(@date2));
// yields the difference in minutes
date_fns.differenceInHours(new Date(@date1), new Date(@date2));
// .. etc. - this also works for days, weeks & so on
Also check out the docs for more info: date-fns - modern JavaScript date utility library
I added some screenshots for reference.
Happy building!
Cheers
Tim
Although the link to Java Script doesn’t work this is the solution! One last thing before closing it: Any chance I can leave the calculation field empty, when one of the fields is empty? If “Closed” field is empty the numbers are insanely high, resulting in a not helpful avg
Sure thing, you could use something like this:
if (@date1 && @date2) {
date_fns.differenceInMinutes(new Date(@date1), new Date(@date2));
} else {
null
}
Thanks for the notice - link has been corrected.
Tim
Oh no, do we have to set up the start and end date with two fields (exactly like Podio)? Why can’t we define the start date and the end date through the same field? Isn’t that waste of space?
I agree with @Roman - is there any way it could be set up so that the Start and End date/time from a single date field can be called in the calculation as separate values and not require two separate date fields for this beginning and ending?
@Roman & @CarsonRedCliffLabs totally feel you. Would any of you be so kind and create a brief, dedicated feature request for that? E.g. “Allow usage of date field end date in calculation fields”.
We can then streamline the discussion there, and hopefully receive more user feedback in order to properly prioritise and tackle this.
Thank you
Tim