Adding a Duration to a Date
You can add or subtract durations, such as 10 days or 12 months, to a date. Continuing with the example of the software company from the previous section, consider determining the date on which each customer's initial tech support contract ends. The data file upgrade.sav contains a variable for the number of years of contracted support and a variable for the initial purchase date. You can then determine the end date of the initial support by adding years of support to the purchase date.
To add a duration to a date:
- Select Calculate with dates and times on the introduction screen of the Date and Time Wizard and click Next.
- In step 1, select Add or subtract a duration from a date and click Next.
- Select Date of initial product license for Date.
- In step 2,
select Years of tech support for
the Duration Variable.
Since Years of tech support is simply a numeric variable, you need to indicate the units to use when adding this variable as a duration.
- Select Years from the Units drop-down list.
- Click Next.
- In step 3, enter SupEndDate for the name of the result variable. Result variables cannot have the same name as an existing variable.
- Enter End date for support as the label for the result variable. Variable labels for result variables are optional.
- Click Finish to create the new variable.
The new variable is displayed in the Data Editor.