Calculates a new date and time by adding an interval to or subtracting an interval from another date and time. The interval is based on a date part, for example, a number of days.
Syntax
_CalculateDateTime(date,interval,datePart)
Parameters
Parameters for _CalculateDateTime
Parameter |
Definition |
Data type |
---|---|---|
date |
Original date and time. |
PFDateTime |
interval |
Time interval to add to or subtract from the original date time. |
Integer |
datePart |
Date part to which the value specified in the interval parameter is added. |
Integer |
Returns
New date time (PFDateTime).
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.
Example
This example sets a date for follow-up that is four weeks after the initial date entered. Both items are on the same form, so the rule is created at the form level. There is no enumeration for weeks in DateTimeParts, so the rule uses twenty-eight days instead of four weeks.
Note: Oracle recommends that you include rule logic to clear the calculated value if a referenced item value is cleared. For example, if a rule calculates BMI based on the values entered in the Height and Weight items, the rule should clear the BMI value if the data in the Height item is deleted. For an example of the appropriate rule logic, see Sample data-entry rules that use methods.
evaluate on Form Submission
value = _CalculateDateTime(this.InitialExamDate.Value, 28, DateTimeParts.Days)
always
set this.FollowupExamDate.Value = value
Copyright © 2013, 2016 Oracle and/or its affiliates. All rights reserved.