Use Time Values in Numerical Calculations

HotDocs Version:HD6, HD2005, HD2006, HD2007, HD2008, HD2009
Word Processor:Microsoft Word, WordPerfect
Added to Knowledge Base:September 2004

In HotDocs, since time values are usually represented with Text variables, if you want to perform a numerical calculation using the answer for a time variable, you must convert each part of the time variable to an integer using the INTEGER expression.

In this example, the computation determines if the time is before 5:00 P.M. The computation's result begins with an initial FALSE value. Then HotDocs determines if the time is in the afternoon (P.M.) by looking for the letter p in the answer. If it is, the script uses the INTEGER expression to convert all the digit characters up to the first non-digit character (the colon) into a numeric value. This number represents the hours portion of the total time. Using the MID expression to locate the two digit characters after the colon, it also converts these characters to an integer and divides the value by 60. This number represents the minutes portion of the total time. These two numbers are added together, and if the result is less than or equal to 5.0 (the equivalent of 5:00), the result is TRUE. Otherwise, the result is FALSE.

Example:
FALSE 
IF Time Var CONTAINS "p" 
  INTEGER( Time Var ) + ( INTEGER( MID( Time Var, 4, 2 ) ) / 60 ) <= 5.0 
ELSE IF Time Var CONTAINS "a" 
  TRUE 
END IF

 Time Var

Any Text variable that uses the 99:99 A.M. time format.