_NormalizeDateToMax (Array)

Normalizes an array of date times by replacing any parts that are UNKNOWN or EMPTY with the maximum value for that part.

Syntax

_NormalizeDateToMax(datesToNormalize)

Parameters

Parameter Definition Data type

datesToNormalize

The array of date times to normalize.

Array of PFDateTime values

Returns

A new array of date times, 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.

You can use arrays called by either the Values() or Objects() property.

Example

The requirement in this example is to find the latest date among all dates in a repeating form, using the MaxValueInArrayDate function. If the date on the repeating form allows users to enter UNKNOWN for days or months, comparing dates without normalizing them can be unpredictable and depends on the sequence of dates in the array. Therefore, use the _NormalizeDateToMax(Array) function to return normalized dates with predictable UNKNOWN parts.

Consider the following arrays of dates, in which the only difference in content is the value of the Day part, which causes the order of the dates to be different in each array:

Table 3-1 ArrayOfDate1

Day Month Year

Date1

18

10

2008

Date2

UNK

10

2008

Table 3-2 ArrayOfDates2

Day Month Year

Date1

UNK

10

2008

Date2

18

10

2008

Table 3-3 Sample function calls

Function call Returned value

MaxValueInArrayDate(ArrayOfDates1)

Date1

MaxValueInArrayDate(ArrayOfDates2)

Date2

MaxValueInArrayDate(_NormalizeDateToMax (ArrayOfDates1))

Date2

MaxValueInArrayDate(_NormalizeDateToMax (ArrayOfDates2))

Date2

MaxValueInArrayDate(_NormalizeDate(ArrayOfDates1, new DateTime(1,1,1)))

Date1

MaxValueInArrayDate(_NormalizeDate(ArrayOfDates2, new DateTime(1,1,1)))

Date1