The Substantial Presence Test (SPT) is the primary way the US decides whether a non-citizen without a green card counts as a resident alien for federal tax purposes in a given year. Pass it, and you're generally taxed like a US citizen on worldwide income for that year; fail it, and you're typically a nonresident alien taxed only on US-sourced income (subject to treaty provisions).
The formula
The test has two parts. First, you must be present in the US at least 31 days during the current calendar year. Second — and this is the part people most often get wrong — you total up a weighted count across three years: all of the current year's days, plus one-third of the prior year's days, plus one-sixth of the year before that. If that weighted total reaches the statutory threshold, you pass the test.
This weighting means someone who spent a lot of time in the US two years ago can still be pulled into US tax residency this year, even with a much shorter current-year stay — the lookback keeps contributing to the total.
Common exceptions
Certain days don't count toward the test at all — for example, days as an exempt individual under specific visa categories (some students and teachers/trainees), days you couldn't leave the US because of a medical condition that arose while there, and days commuting from Canada or Mexico for work. These carve-outs are easy to miss and can change the outcome entirely.
Why the count matters beyond the yes/no answer
Even when the SPT is a close call, the day-count itself feeds into other decisions: whether a first-year or last-year 'dual-status' election makes sense, whether treaty tie-breaker rules under the DTAA need to be invoked, and how residency start/end dates are set for that transition year. Use the Substantial Presence Test calculator on the DTAA & Tax Residency page to run your own day-count and see where you land against the threshold.