Date Difference calculation
The detailed planning Date difference calculation finds the interval between two dates, and returns a vector value representing the elapsed time in the units that you specify (for example, years, months, days). The dates can be attributes, values (that is, a specific date), or the current month, and can be selected from members that are outside of the scenario time period.
Example: For example, Date difference is useful for calculations related to project planning, loans and interest, depreciation and CapEx, and employee years of service.
Parameters
- Start date: The date the employee started working for the company. The options are Value, Attribute (of type Date) and End of Current Month.
- End date: The date the employee finished working for the company. The options are Value, Attribute, and End of Current Month (of type Date).
- Interval: The unit used in measuring the length of time. The options are Days, Months, Quarters, and Years.
- Truncate result: Determines whether the decimal place is removed from the result, so that only whole numbers are displayed, in the chosen interval.
Examples
Difference in years between two dates
The following example calculates the difference between two dates, and shows the result in years, truncated. Note that the Start date is an Attribute, whereas the End date uses End of Current Month.
Current Month | |||||
---|---|---|---|---|---|
Jan2017 | Feb2017 | Mar2017 | Apr2017 | May2017 | |
Start date = Attribute | 2/1/2015 | 2/1/2015 | 2/1/2015 | 2/1/2015 | 2/1/2015 |
End date = End of Current Month | 1/31/2017 | 2/28/2017 | 3/31/2017 | 4/30/2017 | 5/31/2017 |
Number of years elapsed | 1 | 2 | 2 | 2 | 2 |
Number of months until project end
The following example calculates the difference between a Start date (set to End of Current Month) and an End date (set to an Attribute named End of Project) and shows the result in months.
Current Month | |||||
---|---|---|---|---|---|
Jan2017 | Feb2017 | Mar2017 | Apr2017 | May2017 | |
Start date = Current month | 1/31/2017 | 2/28/2017 | 3/31/2017 | 4/30/2017 | 5/31/2017 |
End date = Attribute |
12/31/2017 | 12/31/2017 | 12/31/2017 | 12/31/2017 | 12/31/2017 |
Calculation Result | 11 | 10 | 9 | 8 | 7 |