1.3.11.13 Date Difference

The Date Difference processor compares two date/date array values and returns the difference between the two dates. The difference may be returned in whole years, months, weeks or days, or a combination of these, according to specified options.

Use Date Difference to derive the difference between two dates. For example, if you have a data set of individuals with a Date of Birth attribute, you can use Add Current Date and then Date Difference to calculate the current age of each of the individuals.

The following table describes the configuration options.

The options are used to drive how Date Difference outputs the difference between the two date values for each record. A separate output attribute will be output for Years, Months, Weeks and Days, but the options may be used in combination. For example, if only the Whole days? option is set to Yes, the difference between the dates will be output simply as a number of whole days, but if all options are set to Yes, the difference will comprise a number of years, a number of months, a number of weeks and a number of days, and in this case the number of days can only be a value between 0 and 6 (as 7 days would be a whole week).

Configuration Description

Inputs

Specify exactly two Date attributes.

Options

Specify the following options:

  • Whole years?: determines whether or not to output the date difference in whole years. Specified as Yes/No. Default value: No.

  • Whole months?: determines whether or not to output the date difference in whole months. Specified as Yes/No. Default value: No.

  • Whole weeks?: determines whether or not to output the date difference in whole weeks. Specified as Yes/No. Default value: No.

  • Whole days?: determines whether or not to output the date difference in whole days. Specified as Yes/No. Default value: No.

  • Time zone (subtract from): sets the time zone used to interpret the Subtract From Date. Specified as a time zone. Default value is the Director Time Zone.

  • Time zone (subtracted): sets the time zone used to interpret the Subtracted Date. Specified as a time zone. Default value is the Director Time Zone.

Outputs

Describes any data attribute or flag attribute outputs.

Data Attributes

The following data attributes are output:

  • WholeYears: stores the number of whole years between the two date values. Value is the number of whole years between the two dates.

  • WholeMonths: stores the number of whole months between the two date values. Value is the number of whole months between the two dates.

    If WholeYears is also output, the number of whole months in addition to the last whole year (that is, a number between 0 and 11).

  • WholeWeeks: stores the number of whole weeks between the two date values. Value is the number of whole weeks between the two dates.

    If WholeMonths is also output, the number of whole weeks in addition to the last whole month (that is, a number between 0 and 4).

  • WholeDays: stores the number of whole days between the two date values. Value is the number of whole days between the two dates.

    If WholeWeeks is also output, the number of whole days in addition to the last whole week (that is, a number between 0 and 6).

Flags

None.

If either of the date values being compared is Null, the Date Difference processor cannot calculate a difference between the dates, and so will output null values in all selected output attributes.

The Date Difference processor does not output any summary data. The new date difference attribute(s) are shown to the left of all other attributes in the data view.

Output Filters

None.

Example

In this example, Date Difference is used to derive the age of customers in whole years by comparing a Date of Birth attribute with the current Processing Date. The output attribute is renamed from WholeYears to Age:

ProcessingDate Date of Birth Age

05-Jun-2008 16:03:14

07-Jul-1984 00:00:00

23

05-Jun-2008 16:03:14

21-Jun-1933 00:00:00

74

05-Jun-2008 16:03:14

08-Jun-1913 00:00:00

94

05-Jun-2008 16:03:14

12-Jul-1952 00:00:00

55

05-Jun-2008 16:03:14

02-Jul-1919 00:00:00

88

05-Jun-2008 16:03:14

03-Jan-1915 00:00:00

93

05-Jun-2008 16:03:14

14-Sep-1914 00:00:00

68

05-Jun-2008 16:03:14

17-Feb-1940 00:00:00

68