Computing Time Differences

I have two time/date fields computed on a form, i’d like to have a column in a view compute the time difference between the CompletedTime & the CreatedTime (basically the turnaround time), anyone have any suggestions?

Subject: Computing Time Differences

Subtract the two times, and you’ll get the time difference (in seconds).

You don’t say whether you want the time difference measured in seconds, minutes, hours, days, weeks, months, years, or centuries, but to display the difference as whole number of minutes in a view column, use this formula:

@Integer((CompletedTime - CreatedTime)/60);

Subject: RE: Computing Time Differences

I would like it to show in minutes unless the time is over an hour, then i’d like it to show how many hours & how many minutes & the same thing if it goes over 1 day, then days, hours, & minutes…is that easy to do it all?

Subject: RE: Computing Time Differences

“Easy” is a relative term :wink:

Try something like…

_sec := CompletedTime - CreatedTime;

_days := @Integer(_sec / (60 * 60 * 24));

_hours := @Integer(@Modulo(_sec / (60 * 60); 24));

_minutes := @Integer(@Modulo(_sec / 60; 60));

_text := @If(_days = 0; “”; @Text(_days) + " days ") + @If(_hours = 0; “”; @Text(_hours) + " hours “) + @Text(_minutes) + " minutes”;

@Prompt([Ok]; “Difference”; _text);

Above formula will generate results like:

23 minutes

2 hours 15 minutes

3 days 10 hours 45 minutes

But formatting the time difference like this, prevents you from making that view column sortable, but I assume that is not a requirement.

Consider this a christmas present :slight_smile: