Returns the number of units between two specified dates, based on the requested date part.
Syntax
_GetDateDifference( date1 , date2 , units )
Parameters
Parameters for _GetDateDifference
Parameter |
Definition |
Data type |
---|---|---|
date1 |
First date to use. date1 is subtracted from date2. |
PFDateTime |
date2 |
Second date to use. |
PFDateTime |
units |
Unit to use when computing the difference. Units are taken from DateTimeParts: Years, Months, Days, Hours, Minutes, Seconds. |
Integer |
Returns
A positive, zero, or negative interval length depending on whether the first date is earlier than, equal to, or later than the second date. Unknown date parts are normalized. Results are rounded down.
Notes
Note: If the time period includes a February month with 29 days, then 366 days equal 1 year. Otherwise, 365 days equal 1 year.
For example, if a start date is in a month with 31 days, then 31 days from the start date is one month. If the date range goes from February until September, then each month's number of days is used for the calculation. For example, 28 (or 29, if February has 29 days) days from the start date in February is one month; 31 days from the date in March is another month; 30 days from the date in April is another month; and so on.
For increments that are fewer than 28, 29, 30, or 31 days, depending on the month, the range is 0 months.
_GetDateDifference (new DateTime(2007,1,10,0,0,0), new DateTime (2007,2,1,0,0,0), DateTimeParts.Months)
Example
The _GetDateDifference function is used to determine how long an adverse event lasts and to store the result in an item. This rule is attached to the AE form, which contains the OnsetDate and EndDate items, as well as an AEDuration item to store the calculated value.
evaluate on Form Submission
value = _GetDateDifference(this.OnsetDate.Value, this.EndDate.Value, DateTimeParts.Days)
always
set this.AEDuration.Value = value
If OnsetDate is January 1, 2008, and EndDate is January 6, 2008, the function returns 5.
Copyright © 2013, 2016 Oracle and/or its affiliates. All rights reserved.