Date comparison
Compare two date questions that do not have fields for an exact time (hour and minutes) and raise a query if the dates for those questions are not as expected.
Rule description: the Onset Date value must be on or before the Date of Completion value, or else a query is raised.
Rule expression
//to meet the rule description criteria onstdt-compdt should be a negative value or zero (<=0)
if(dateDiffInDays(onstdt,compdt)<=0)
{
return true;
}
else
{
return false; //System sends query when return false condition is met
}
Query Message: The Onset Date is after the Date of Completion. Please correct or confirm the date(s).
Definitions
- onstdt
-
Corresponds to the Onset Date from the rule description.
- compdt
-
Corresponds to the Date of Completion from the rule description.
- <=
-
Less Than or Equal To operator. Update the operator based on the rule description.
- dateDiffInDays
-
Calculates the difference between date1 (onstdt) and date2 (compdt) (date1-date2) in days.
Return value
Usage tips
Always use the relevant date helper function to compare dates rather than directly comparing the variables using comparison operators.
Verification steps
- Using a subject for testing, go to the given visit and form
containing the date items to compare, in this example the onset date
<
onstdt
> and date of completion <compdt
>. - Update the form items
onstdt
andcompdt
as in the following table and verify the result is as listed:onstdt
compdt
Result 10-May-2021 Null
No query 10-May-2021 10-May-2021 No query 11-May-2021 10-May-2021 Query 09-May-2021 10-May-2021 No query 09-Jun-2021 10-May-2021 Query 11-Apr-2021 10-May-2021 No query Null
10-May-2021 No query 12-May-2021 10-May-2021 Query 12-May-2021 14-May-2021 No query
Note:
Repeat the above steps if the form is present in multiple visits.
Other examples
Example 4-11 Date of Death must be greater than or equal to the Date of Randomization
if(dateDiffInDays(deathdt,randt)>=0)
{
return true;
}
else
{
return false;
}
Query message: The Date of Death is prior to the Randomization Date. Please correct or confirm the date(s).
Example 4-12 The Date of Completion or the Withdrawal Date must be equal to the Date of Death
//Apply this rule when Reason for discontinuation is 'death'
if(dateDiffInDays(compdt,deathdt)===0)
{
return true;
}
else
{
return false;
}
Query message: Reason for discontinuation is death, the Date of Completion or the Withdrawal Date must equal the Date of Death. Please correct or confirm the date(s).
Example 4-13 Start date of hypoglycaemic episode must be <== Date of subject withdrawal
Note: The hypoglycaemic episode is a date and time question, time elements are ignored in this logic.
if(dateDiffInDays(hypodt,withdrawdt)<=0)
{
return true;
}
else
{
return false;
}
Query message: The date of the hypoglycaemic episode is after the subject ended the trial. Please correct or clarify.
Example 4-14 Medical History Start Date must be on or after Date of Birth
if(dateDiffInDays(mhstdt,dob)>=0)
{
return true;
}
else
{
return false;
}
Query message: Start Date is before the Date of Birth on the Demographics form. Please correct the date(s).
Parent topic: Date comparisons