Duration
A period of time, specified as a number of years, months, and days.
Syntax:
yearsy monthsm daysd
Case is ignored.
Examples:
3y2m15d equals 3 years, 2 months, and 15 days
15y equals 15 years
36m equals 36 months (and equivalent to 3Y)
15d equals 15 days
Durations can be scaled up by multiplication. If the field SERVICE contains the value 22.5, then (1y * SERVICE) returns 22.5 years.
Duration is used to add/subtract units of time to/from dates using the #DATEPLUS and #DATEMINUS operators. These operators perform date calculations based on the average number of days in a year and the average number of days in a month:
365.25 is the average number of days in a year: (365 + 365 + 365 + 366) /4 or 31 + 28.25 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31, where 28.25 is the average number of days in February, (28 + 28 + 28 + 29)/4.
30.4375 is the average number of days in a month: 365.25 / 12.
Code | Result | Comments |
2/1/2001 #DATEPLUS 31D | 3/1/2001. | That's because the duration 31D is converted into 1 month (1M) and 0.5625 days (=31-30.4375*). |
2/1/2001 #DATEPLUS 1M |
3/1/2001 |
and since 0.5625 is less than one day, it has no effect on the calculation of the final date. |
#DATEPLUS converts the duration 90D into 2 months and 29.5625 days, so 7/16/2013 + 2 months is 9/16/2013, and plus 29 (29.5625) days, is 10/15/2013. |
||
7/16/2013 #DATEPLUS 1M |
10/15/2013. |
If you subtract these 2 dates in Excel, you'll get 91 days. 10/15/2013 - 7/16/2013 = 91 |
Depending on the date you start with, adding 1600D (mm/dd/yyyy #DATEPLUS 1600D) and subtracting the dates in Excel, the difference could be 1597, 1598, 1599, 1600, or 1601 days. That’s because when using #DATEPLUS and #DATEMINUS, 1600D is not 1600 days, but a duration of 4Y4M17D |
||
7/16/2013 #DATEPLUS 1600D |
12/3/2017. |
#DATEPLUS converts the duration 1600D into 4 years (#FLOOR 1600/365.25), 4 months (#FLOOR (1600-365.25*(#FLOOR 1600/365.25))), and 17.25 days. So, 7/16/2013 + 4 years is 7/16/2017, plus 4 months is 11/16/2017, and plus 17 days is 12/3/2017. |
they can have unexpected consequences: INDEX ERRORS, DOMAIN ERRORS, and the inability of ProAdmin to determine if 2 dates are equal. For example, B is not equal to 7/16/2016 (D1 is zero) while C is (D2 is one). While there are differences between actual days and durational days, there are no such problems with actual years and months because and year and month durations are equivalent: 36M is the same as 3Y, and 1Y*22.5 is the same as 22Y6M or 270M. |