_NormalizeDate (PFDateTime, PFDateTime)
Normalizes a single date by replacing the parts that are entered as UNK with the date part values in the specified template.
Syntax
_NormalizeDate(dateToNormalize,template)
Parameters
Parameters for _NormalizeDate (PFDateTime, PFDateTime)
Parameter |
Definition |
Data type |
dateToNormalize |
Date time value to normalize by replacing UNK date time parts from a template. |
PFDateTime |
template |
Date time value containing the date and time part values with which to replace UNK date and time parts. This template contains no unknown parts. |
PFDateTime |
Returns
A normalized date time in which all UNK parts are replaced with the corresponding part from the template.
Notes
During normalization, the appropriate date time part value from the specified template, in Year-Month-Day-Hour-Minute-Second format, is substituted for each UNK date time part. Any date time parts that are not allowed in the definition of the date time field are replaced with values from the template. For example, if the value of the dateToNormalize is 1987-04-UNK and the value of the template is 1980-01-01, the normalized value is 1987-04-01.
Example
In this example, the Start Date and End Date of an adverse event are compared to make sure that the End Date is after the Start Date. However, the patient may not know the exact start and end dates of the adverse event, so the Day part of the date time fields is set to Allow Unknown. A valid comparison requires that the dates first be normalized. Then the rule uses the _CompareDates function to compare the dates and creates a query if StartDate is later than EndDate. When normalizing, the function substitutes 1 when the day is omitted.
evaluate on Form Submission
value = _CompareDates(
_NormalizeDate(this.EndDate.Value, new DateTime(2007, 1, 1, 0, 0, 0)),
_NormalizeDate(this.StartDate.Value, new DateTime(2007, 1, 1, 0, 0, 0))
)
when value == -1
issue query on this.EndDate: End Date cannot be prior to Start Date