These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Using Time for calculations

cpuguruaz
Registered: Jan 31 2011
Posts: 3
Answered

Good Morning,
 
I use the following formula to calculate elapsed time. IE: 0800 to 0845 = 45 minutes.
 
var elapsed = (Time2Num(end_pump.formattedValue, "HH:MM:SS") - Time2Num(start_pump.formattedValue, "HH:MM:SS")) / (1000 * 60)
var Hrs = Ltrim(Str(Floor(elapsed / 60)))
var Mins = Right(Concat("0", Ltrim(Str(Mod(elapsed, 60)))), 2)
Concat (Hrs, ":", Mins)
  
My problem is, I need to use that elapsed time elsewhere as part of a calculation and I cannot figure out how to utilize it. My specific need is this. I am trying to calculate the flow rate on a pump. I take the number of gallons pumped out and divide it by the number of minutes. Of course, left as is, and I get a divide by zero error. I have tried to use Time2Num on the results, but I am not sure what format the output is or if its even still considered a time after the above procedure, so the result is always a zero.
 
Specs: I am using Live Cycle 8 and we use Military Time.
 
Any thoughts or suggestions will be greatly appreciated. Thanks for the help!
Mike

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You have to make sure your divisor is not zero before performing a division. Write an if then statement to test for a non-zero divisor and then perform the division for a true result of the statement. Also you need the elapsed time in a single time measurement unit as a number and not a character string.

George Kaiser

cpuguruaz
Registered: Jan 31 2011
Posts: 3
Hello George,

Thanks for the reply. Any suggestions on how to make it a single time measurement unit as a number? Thanks again for the help. It is truly appreciated.

Mike


gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
You convert your hours, minutes, seconds, etc to minutes.

You code:

var elapsed = (Time2Num(end_pump.formattedValue, "HH:MM:SS") - Time2Num(start_pump.formattedValue, "HH:MM:SS")) / (1000 * 60)

Has already done the heavy work. You could save that value in a field and use it wherever you need it.

George Kaiser

cpuguruaz
Registered: Jan 31 2011
Posts: 3
George,

Excellent! Thanks so much for your help.

Have a great day. Thanks again :>Mike