Previous Topic

Next Topic

Book Contents

_GetDateDifference

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

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.

Send Feedback