_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
Parameters for _NormalizeDateToMax(Date)
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.EVTEND.Value),
_NormalizeDate(this.EVTSTART.Value, new DateTime(1,1,1)),
DateTimeParts.Days)
Sample returned values
Sample returned values
Start date
End date
Returned value
Feb 02, 2008
Oct 13, 2008
254 days
Feb UNK, 2008
Oct UNK, 2008
273 days. The start date is converted to Feb 1, 2008, and the end date is converted to Oct 31, 2008.
UNK UNK, 2008
UNK UNK, 2008
365 days. The start date is converted to Jan 1, 2008, and the end date is converted to Dec 31, 2008