_NormalizeDate (PFDateTime, PFDateTime, PFDateTime)

Normalizes a specified date and a reference date by replacing the parts that are entered as UNK with the date part values in the specified template. This function is used to normalize two dates that are being compared. It makes sure that the unknown parts in both dates are considered when determining which parts to normalize.

Syntax

_NormalizeDate(dateToNormalize,referenceDate,template)

Parameters

Parameter Definition Data type

dateToNormalize

Date time value to normalize by replacing UNK date time parts from a template.

PFDateTime

referenceDate

Second date time value to normalize by replacing UNK date time parts from a template. This date can be compared to the dateToNormalize after both dates are normalized.

PFDateTime

template

Date time value containing the date and time part values with which to replace UNK date and time parts.

PFDateTime

Returns

A new date with all UNK parts replaced with the corresponding part from the template.

Notes

This function uses a second date as a reference. If either the date to normalize or the reference date has any UNK parts, those parts will be replaced with the corresponding part from the template. For example:

  • dateToNormalize—2007/2/5.
  • referenceDate—2006/5/UNK.
  • template—2005/1/1.
  • Normalized result for dateToNormalize—2007/2/1, even though its Day part is not unknown.

Since the reference date has an unknown Day part, both dates are normalized. For more information, see Date time processing.

Example

In the following example, the _NormalizeDate function is used within the _CompareDates function to normalize two dates that have unknown parts:

  • date1—1987-0-UNK-14:45.
  • date2—1987-2-7-10:UNK.
  • template—1981-10-1-0:0:0.

_CompareDates ((_NormalizeDate (date1, date2, new DateTime (1981,10,1,0,0,0)),(_NormalizeDate (date2, date1, new DateTime (1981,10,1,0,0,0))).

Step Result

The first date, date1, is normalized against the template 1981,10,1,0,0,0 with date 2 as a reference.

normalized date1 = 1987-0-1-14:0:0.

The second date, date2, is normalized against the template 1981,10,1,0,0,0 with date 1 as a reference.

normalized date2 = 1987-2-1-10:0:0.

The two normalized results are compared.

1 (date2 is greater than date1).