Dependent Date Shift
The Dependent Date Shift algorithm masks two dates while maintaining a dependency between them. Examples of such dependent date pairs include:
-
date of admission and date of discharge
-
date of birth and date of death.
The Dependent Date Shift algorithm adjusts date values relative to their original value by applying a calculated time offset. It is designed to preserve meaningful relationships between dates while ensuring that the resulting values differ from the source data.
What the algorithm does
Instead of replacing dates with fixed or random values, the Dependent Date Shift algorithm derives a new date by adding or subtracting a time offset from the original date. The offset is selected from a range you define and applied using a specified time unit.
This approach helps maintain realistic timelines and preserves the relative ordering of events, which is often important for testing, analytics, and application behavior.
How date shifts are calculated
The algorithm calculates date shifts using the following inputs:
- Range – Defines the minimum and maximum offset that can be applied to the original date.
- Interval – Defines the range by which the time gap between the two dates can vary. A value of 0 preserves the original gap exactly. A larger value allows the gap to be adjusted by up to that many units in either direction (while preserving which date comes first).
- Shift unit – Defines the unit of time (for example, days or months) used when applying the offset.
The resulting date is always derived from the original value, ensuring that shifts remain consistent and predictable within the defined bounds.
Supported time units
Date shifts can be applied using the following time units:
- Years
- Months
- Days
- Hours
- Minutes
- Seconds
Roll behavior
The algorithm supports optional roll behavior when applying date shifts.
-
When roll is enabled, only the selected Shift Unit field changes — all units larger than the Shift Unit remain unchanged. For example, if shifting by days, the month and year do not change.
-
When roll is disabled, standard date arithmetic is applied — a shift that crosses a period boundary will change higher-order fields. For example, shifting a January date forward by 5 days can change the month to February.
Examples
The following examples illustrate how the Dependent Date Shift algorithm applies offsets to an original date.
Example 1: Shifting two related dates
- Minimum Range: 1
- Maximum Range: 10
- Interval: 2
- Shift Unit: Days
Let's say the original dates are:
-
date1: 2024-03-01
-
date2: 2024-03-08 (7 days after date1)
The algorithm shifts date1 by a value between 1 and 10 days. The Interval is set to 2, meaning the gap between the two masked dates can differ from the original 7-day gap by up to 2 days — the masked gap will be between 5 and 9 days. For example, if date1 is shifted to 2024-03-06, date2 will fall between 2024-03-11 and 2024-03-15.
Example 2: Shifting by months with roll enabled
- Minimum Range: 1
- Maximum Range: 3
- Interval: 1
- Shift Unit: Months
- Roll: Enabled
The algorithm applies a shift of one to three months. When Shift Unit is set to Months and the day of the original date is higher than the number of days in the target month, the day is adjusted to the last valid day of that month. The date does not advance into the following month.
For example, shifting January 31 forward by one month targets February 31, which does not exist. In this case, the day is clamped to the last valid day of the target month — February 28 in a common year, or February 29 in a leap year — without advancing into March.
Example 3: Preserving relative order of dates
When multiple related dates are processed using the same configuration, each date is shifted relative to its original value. Earlier dates remain earlier than later dates, even after shifting.
This behavior makes the Dependent Date Shift algorithm well suited for datasets where the sequence and spacing of events must remain realistic.
When to use this algorithm
Use the Dependent Date Shift algorithm when you need to:
- Preserve relative timing between related dates
- Maintain realistic date distributions
- Ensure consistent, repeatable date transformations
This algorithm is commonly used for masking dates in datasets where the relationship between events is more important than the exact values.