Data Management
Define Protocol Days Before Counting Calendar Dates
Choose the convention before assigning a visit
A protocol day label and a date difference need not be identical. A study may label its reference date day 1 while ordinary subtraction gives zero elapsed days on that same date. Write the convention explicitly before using day labels to classify visits or protocol deviations.
The Python date documentation defines calendar-date arithmetic separately from timestamp operations. Use date-only differences for questions about calendar dates, and a suitably specified timestamp calculation when the question concerns elapsed hours or an exact event time.
Separate three useful quantities
Elapsed calendar days count the difference between two dates. An inclusive count of calendar dates adds one when both endpoints are included and the end is not before the start. A protocol day index follows the study's own rule and may require special treatment before the reference date.
For example, a convention with reference day 1 and no day 0 could assign the previous date day −1. That is not achieved by adding one to every signed date difference. Treat this as an explicitly defined example, not a universal standard for all studies or data submissions.
Test leap-day boundaries with fictional dates
From 28 February 2024 to 1 March 2024 there are two elapsed calendar days because 2024 contains 29 February. Counting both endpoint dates gives three calendar dates. Under a reference-date-as-day-1 convention, 1 March is study day 3 when 28 February is the reference.
In 2023, the same month-and-day endpoints are one elapsed day apart and include two calendar dates. The ISO-date interval tool can illustrate valid date-only differences and inclusive counts. It requires exact YYYY-MM-DD dates, years 1000–9999, and end on or after start. Its day-zero and day-one outputs cover this nonnegative interval only; they do not implement negative study-day conventions.
Audit anniversaries and boundaries
Do not replace a calendar month with thirty days unless the specification actually defines that duration. One month after a date and thirty elapsed days can lead to different endpoints. A February 29 anniversary in a non-leap year also needs an explicit rule; ordinary day subtraction cannot decide whether a protocol means February 28 or March 1.
Use the date-duration worksheet to record the reference event, day-zero or day-one convention, endpoint inclusion, and applicable window. Test the reference date itself, the preceding date, leap-day examples, and both edges of a permitted visit window.
Keep these derived labels separate from the original dates. If a convention changes, regenerate the labels reproducibly rather than editing individual records until the windows look correct. Investigate negative or impossible intervals without silently reversing dates.
Finish with a short set of expected boundary results that another analyst can rerun. This focused convention check complements the existing date-quality audit: validly parsed dates can still be classified incorrectly if elapsed duration, inclusive counting, and protocol indexing are confused.
Source checked on 3 November 2026; fictional date differences independently recalculated.