1.3.10.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:
|
Outputs |
Describes any data attribute or flag attribute outputs. |
Data Attributes |
The following data attributes are output:
|
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 |