Field notes

Excel formulas for a visit window: earliest date, latest date, and the next visit

A window is two offsets from a date. Here are the formulas, a worked example for "between 21 and 3 days before Visit 2", and a small sheet that chains each visit off the one before.

Every visit window is two numbers added to one date. Put the date the window counts from in one cell, the two offsets in two more, and add:

  • Earliest date: =B2+C2
  • Latest date: =B2+D2

B2 is the date the window counts from, C2 is the earliest offset in days and D2 is the latest offset in days. Use negative numbers for "before". Format the two result cells as dates. That is the whole calculation; the rest of this page is the cases that trip people up.

The example: 21 to 3 days before Visit 2

Say the protocol wants a lab draw between 21 and 3 days before Visit 2, and Visit 2 is on Tuesday, April 14, 2026.

CellWhat goes in itValue
B2Date the window counts from (Visit 2)Apr 14, 2026
C2Earliest offset−21
D2Latest offset−3
E2=B2+C2Mar 24, 2026
F2=B2+D2Apr 11, 2026

The draw can happen from Tuesday, March 24 through Saturday, April 11. If your site is closed on weekends, the last day you can really use is Friday, April 10 (there is a formula for that below).

Both offsets are negative here because the whole window sits before Visit 2. A window that sits after a visit has two positive offsets, and one that straddles a target date has one of each.

The more common shape: a target day, plus or minus

Most schedules of assessments give a target day and a tolerance, such as "Week 4 (Day 28) ±3 days". That is the same arithmetic with one more step.

ColumnHeaderFormula in row 2
AVisit(type the name)
BCounts from(a date)
CTarget day(days after column B, such as 28)
DDays before allowed(such as 3)
EDays after allowed(such as 3)
FTarget date=B2+C2
GEarliest=F2-D2
HLatest=F2+E2
IActual visit date(type it when the visit happens)
JStatussee below
KDays left=IF(I2="",H2-TODAY(),"")

The two tolerances are separate columns on purpose. Plenty of protocols allow −2/+5 or −0/+3, and a single "±" column cannot hold those.

Check the day numbering before you type the target day. If your protocol calls the first-dose day Day 1 and has no Day 0, Week 4 is written as Day 29 but is 28 days after the anchor. Type 28, not 29. Day 0 or Day 1? has the full explanation.

A status that tells you what to do today

Put this in J2 and fill it down:

=IF(I2="",IF(TODAY()>H2,"Overdue",IF(TODAY()>=G2,"In window","Upcoming")),IF(AND(I2>=G2,I2<=H2),"Done in window","Done out of window"))

With no actual date it compares today to the window. Once you type the actual date it tells you whether the visit landed inside. "Done out of window" is the one to act on; what happens next is in Is an out-of-window visit a protocol deviation?

Making the next visit count from the last one

There are two ways a protocol can place the next visit, and the formula in column B is the only thing that changes.

Every visit counts from the same anchor (randomization, first dose, baseline). Put the anchor date in one cell, say $B$1, and set column B of every row to =$B$1. The dollar signs keep the reference from sliding when you fill down. A late Week 4 does not move Week 8.

Each visit counts from the visit before it. In row 3, set column B to:

=IF(I2="",F2,I2)

That reads: if the previous visit has not happened yet, plan from its target date; once it has an actual date, count from that. Type an actual date in row 2 and row 3's target, earliest and latest all move. Cycle-based schedules usually work this way.

Which one applies is a protocol question, not a spreadsheet question. Missed a visit: which date do you count from? covers how to tell, and some protocols use both at once for different procedures.

When the earliest or latest day lands on a weekend

The protocol's window is in calendar days, so keep the true dates in columns G and H. Add two helper columns for the days your clinic can actually book:

  • First open weekday on or after the earliest date: =WORKDAY(G2-1,1)
  • Last open weekday on or before the latest date: =WORKDAY(H2+1,-1)

WORKDAY skips Saturdays and Sundays. To skip your site's holidays too, list them in a range and pass it as the third argument: =WORKDAY(H2+1,-1,$N$2:$N$12). In the example above, a latest date of Saturday, April 11 becomes Friday, April 10.

Do not replace the real window with the weekday version. The monitor compares the visit date to the protocol's window, and you want the sheet to show both.

Four things that break these formulas

  1. A date typed as text. If a date sits on the left side of its cell or =ISNUMBER(B2) returns FALSE, Excel sees text and the addition returns an error. Retype it, or use =DATEVALUE(B2) in a helper column.
  2. A result that shows a number like 46126. That is a date Excel has not been told to display as one. Format the cell as a date.
  3. A reference that slides. If every row should use one anchor cell, write it as $B$1. Without the dollar signs, filling down points row 3 at B2, row 4 at B3, and so on.
  4. An offset with the wrong sign. "21 days before" is −21. A positive 21 puts the window on the other side of the visit and nothing warns you.

These formulas work unchanged in Google Sheets.

If you would rather not build it

The free visit window tracker spreadsheet has all of this in it, with the day-numbering switch and the chain-from-previous option as settings. For a one-off, the visit window calculator takes a pasted schedule and an anchor date and shows every window in your browser, with nothing saved.

Questions

How do I calculate a visit window in Excel?

Add the earliest and latest offsets to the date the window counts from: =B2+C2 for the earliest date and =B2+D2 for the latest, where B2 is the reference date and C2 and D2 are the offsets in days. For a target day with a tolerance, compute the target first (=B2+C2), then subtract the days allowed before and add the days allowed after.

How do I make the next visit window update when a visit happens late?

Point the next row's reference date at the previous row with =IF(I2="",F2,I2), where I2 is the previous visit's actual date and F2 is its target date. The next window is planned from the target until the visit happens, then recalculates from the actual date. Only do this if your protocol counts each visit from the one before.

Can a visit window be entirely before another visit?

Yes. A window such as "21 to 3 days before Visit 2" has two negative offsets, −21 and −3, both added to the Visit 2 date. The earliest date is the more negative one.

Does Excel count weekends in a visit window?

Plain date addition counts every calendar day, which is what most protocols mean. Use WORKDAY only to find the nearest day your clinic is open, and keep the true calendar window next to it.