Insert a Date in Three Separate Fields

From HotDocs Wiki

Jump to: navigation, search

Sometimes, especially when automating form templates, a Date variable must be divided into three separate fields: month, day, and year. If you use the same Date variable in each field, but change the format to the day (03), month (06), or year (90), your template may contain three separate fields:

«Date Var:06» (mm)
«Date Var:03» (dd)
«Date Var:90» (yy)

Unfortunately, the first two format examples are ambiguous enough that HotDocs isn't sure where to insert the correct parts of the date. (Both 06 and 03 can represent months.) When a user enters a date in the first field, HotDocs looks at the Date detection order in HotDocs Options and interprets the first chunk of numbers in the answer as a month. Because the format example calls for only one portion of the date, HotDocs stops processing it, inserts the first number that meets the criteria specified in the format example, and then moves to the next field where it attempts to process the same date again. Often the end result is 06/06/90 rather than the correct result of 06/03/90.

To display Date variables correctly in three separate fields, you can create three Computation variables—one for each field. Each computation will extract the appropriate part of the date. Using three separate computations, the template looks like this:

«Month Comp» (mm)
«Day Comp» (dd)
«Year Comp:90» (yy)

Example

Note: HotDocs can recognize dates entered in two orders: month-day-year (the default order in the United States) and day-month-year (the default outside the U.S.). You can select the default date entry order at HotDocs Options. The following computations compute the month, day, and year of a Date variable. Date Var is any Date variable.

//Month Computation
MONTH OF( Date Var )
 
//Day Computation
DAY OF( Date Var )
 
//Year Computation (4-digit year; use 9999 for the format)
YEAR OF( Date Var )
 
//Year Computation (2-digit year; use 09 for the format)
REMAINDER( YEAR OF( Date Var ), 100 )

Note on HotDocs 2009 and Later

HotDocs 2009 introduced several new format examples for dates, which allow you unambiguously format any part of a date without resorting to computations as shown above. For example:

«Date Var:mm» (The month as a 2-digit number)
«Date Var:dd» (The day as a 2-digit number)
«Date Var:yy» (The year as a 2-digit number)

See the topic "Additional Date Formats" in the HotDocs help file for a complete listing of date formats you can use in HotDocs 2009 and later.