getFormSubmitDate()

Retrieves either the form start, completion, or last updated date.

Note:

Rules run whenever the target or any other rule global variable is updated and submitted. If you want to get updated with the form start, completion or last update date in real time, make sure you reference all the required questions as variables to ensure the rule runs whenever any of those questions gets updated.

Syntax

getFormSubmitDate(param)

Parameters

Parameter Required or Optional Description
param Required
A string value that can have one of the following values:
  • start: Use this value to get the form's start date.
  • completion: Use this value to get the date of the first time that all the required questions were answered in the form.
  • lastupdate: Use this value to get the date of when the last update to the form took place.

Note: If the form is cleared or deleted and then data is re-entered, start and completion dates would return the date of the most recent start or completion, respectively.

Return value

Returns a date, depending on the provided parameter:
  • Form start date.
  • Form completion date.
  • Form last updated date.

    Note:

    If the form is restored, for the last updated data this function returns the date when the form was restored until it is updated again.
The date is always in the site's local time, based on the time zone specified for the site, and is always in the same format as system dates: ddd MMM DD YYYY HH:mm:ss GMT±hhmm (GMT±h). For example Thu May 08 2025 00:00:00 GMT+0000 (GMT).

Usage tips

  • If you intend to compare any of these dates with dates associated with The Subject Object, keep in mind the time zone difference. Dates associated with the subject object are returned in GMT, while dates retrieved with the getFormSubmitDate() rule helper function (as well as any site entered dates) are always in the site's local time.
  • If you are using the logMsg() function to Debug a rule, the debug output displays the timestamps of the dates retrieved with the getFormSubmitDate() rule helper function (as well as site entered dates) with an associated time zone of GMT. However, these dates are always in the site's local time.
  • If the completion date is used as the return of a calculation rule to populate on a question, and it is the last variable to be updated, the completion date won't get returned until another referenced question on the form is updated. A calculation rule cannot reference a question populated by a calculation rule as a variable.

Examples

Example 3-112 Get date difference in days between the form completion date and any other date

var cDate = getFormSubmitDate('completion');
 
if(cDate!=null && testDate!=null)
{
    var res = dateDiffInDays(cDate,testDate);    //testDate may be, for example, the visit date as entered by the site user
    return res;
}