_NormalizeDateToMax (Date)

Normalizes a single date time value by replacing any parts that are UNKNOWN or EMPTY with the maximum value for that part.

Syntax

_NormalizeDateToMax(dateToNormalize)

Parameters

Parameter Definition Data type

dateToNormalize

The date time to normalize.

PFDateTime

Returns

A new date time with all UNKNOWN or EMPTY parts replaced with their respective maximum values:

  • Year—9999
  • Month—12
  • Day—(Last day of the month that year)
  • Hour—23
  • Minute—59
  • Second—59

Notes

The _NormalizeDateToMax function accounts for leap years and returns the correct number of days in February of any year.

Example

The requirement in this example is to find the duration of a previous disease by subtracting the disease start date from the disease end date in the medical history. An unknown month and day are allowed for both start date and end date. An additional requirement is to substitute unknown date parts with the earliest number for start date and with the latest number for end date so that the longest possible duration of disease is assumed.

To accomplish this:

  • Normalize the start date to January 1 of any year.
  • Normalize the end date to one of the following:
    • December 31 of any year.
    • The last day of the given month if the month is known.
      _GetDateDifference(
          _NormalizeDateToMax (this.EVTSTART.Value, new DateTime(1,1,1)),
          _NormalizeDate(this.EVTSTART.Value, new DateTime(1,1,1)),
          DateTimeParts.Days)