IRS Substantial Presence Test (183-Day) Calculator
Applies the substantial presence test in section 7701(b)(3) of the tax code. You meet it with at least 31 days in the United States this year and at least 183 weighted days: all of this year's days, a third of last year's and a sixth of the year before's. It counts in sixths, 6 × this year + 2 × last year + the year before against 1,098, and finds the most days this year that stay under the test.
Enter the days you were in the United States this year, last year and the year before, leaving out any days that don't count. The calculator weights them as the tax code does, says whether you meet the substantial presence test, how far you are from 183 days and the most days you could spend in the country this year without meeting it. The defaults are the IRS's own example: 120 days in each of three years.
How the test works
Section 7701(b)(3)(A) of the Internal Revenue Code makes a foreign national a US resident for tax if they were present in the United States on at least 31 days during the calendar year, and the weighted sum of their days over three years reaches 183. The IRS's substantial presence test page puts it as counting "All the days you were present in the current year", "1/3 of the days you were present in the first year before the current year" and "1/6 of the days you were present in the second year before the current year".
weighted days = this year + last year ÷ 3 + year before ÷ 6
Thirds and sixths don't divide evenly, so the calculator counts in sixths of a day to avoid rounding errors. Multiplying both sides of the test by six gives whole numbers:
6 × this year + 2 × last year + year before ≥ 1,098
The table shows each year's days, the share counted and the result, so you can check the sum.
Which days count
Publication 519 says "You are treated as present in the United States on any day you are physically present in the country at any time during the day." Arriving at 11 pm counts as a full day. The statute's section 7701(b)(7) says the same. Publication 519 then lists days that don't count:
- days you commute to work from a home in Canada or Mexico, if you do so on more than 75% of workdays
- days in the United States for less than 24 hours in transit between two places outside it
- days as a regular crew member of a foreign vessel
- days you intended to leave but couldn't, because of a medical condition that arose while you were here
- days you are an exempt individual
Exempt doesn't mean exempt from tax. It covers foreign government-related individuals on A or G visas, other than A-3 and G-5 household staff; teachers and trainees on J or Q visas; students on F, J, M or Q visas who substantially comply with their visa; and professional athletes here for a charitable sports event. The exemptions run out. A student generally stops being exempt after any part of more than 5 calendar years, and a teacher or trainee after being exempt in any part of 2 of the 6 preceding calendar years, with exceptions Publication 519 sets out. Exempt teachers, trainees, students and athletes file Form 8843 to exclude the days. Enter only the days that count.
The most days you can stay
Because the weights are fixed, the days you have already spent in the two earlier years decide how many you can spend this year. The calculator solves the test for this year's days:
most days = ⌈(1,098 − 2 × last year − year before) ÷ 6⌉ − 1, and never fewer than 30
The floor of 30 is the 31-day rule: whatever happened in the earlier years, 30 days in the current year can't meet the test. The most anyone can spend without meeting it is 182 days, by someone with no days in the past two years. After two full years of 365 days in the country, the figure drops to 30.
A worked example
On the defaults, 120 days this year count in full. A third of last year's 120 days is 40.00, and a sixth of the year before's 120 is 20.00. That is 180.00 weighted days, 3.00 days short of 183, so the test is not met, the same answer the IRS reaches in its example. In sixths, 720 + 240 + 120 is 1,080, under 1,098. Up to 122 days this year stays under the test, and 123 days would make the total exactly 183.00, which meets it.
Visa-holders tracking days for other systems often need several counts at once. The Schengen 90/180-day calculator handles a rolling window rather than calendar years, and the Canada PR residency obligation calculator counts days against a five-year period.
Meeting the test but staying a nonresident
Publication 519 sets out the closer connection exception. Even if you meet the test, you can be treated as a nonresident if you were present for less than 183 days during the year, kept a tax home in a foreign country all year and had a closer connection to that country than to the United States. Contacts that show a closer connection include where your permanent home, family and belongings are, where you vote and hold a driver's license, and the residence you name on forms. You must attach Form 8840 to your return, filed by the Form 1040-NR due date, and you can't claim the exception if you applied for or had a pending application to become a permanent resident during the year.
A tax treaty can also settle the question. If you are a resident of both countries under their laws and the treaty has a tie-breaker rule that makes you a resident of the other country, you are treated as a nonresident in figuring US income tax, and you file Form 1040-NR with Form 8833.
A short history
The test is in section 7701(b), which Public Law 98-369, enacted on 18 July 1984, added to the code. Its effective date note applies it to "taxable years beginning after December 31, 1984". The 1984 law moved the subsection that had held that slot, on the words "includes" and "including", to section 7701(c).
What the calculator leaves out
The test is one of two routes to residency for tax; a lawful permanent resident is a resident under the green card test whatever the day count, and the green card travel calculator tracks absences for naturalization instead. The calculator doesn't decide first-year or last-year residency dates, dual-status years, elections or state residency rules, which have their own tests. It is not tax advice.
Frequently asked questions
What is the substantial presence test?
It is the day count the IRS uses to decide whether a foreign national who doesn't hold a green card is a US resident for tax. You meet it if you were in the United States on at least 31 days this year and on at least 183 days over three years, counting all of this year's days, a third of last year's and a sixth of the year before's.
How many days can I spend in the US without becoming a tax resident?
It depends on the two previous years. After 120 days in each of them you can spend up to 122 days this year, while 123 would meet the test. With no days in the past two years the most is 182. After two full years of 365 days, only 30 days are safe, because the test also needs 31 days in the current year.
Does a partial day in the United States count?
Yes. You are treated as present on any day you are physically in the United States at any time during the day. The exceptions are days commuting regularly from Canada or Mexico, transit stops of under 24 hours between two foreign places, days as crew of a foreign vessel, days you couldn't leave because of a medical condition that arose here, and days as an exempt individual.
Who is an exempt individual for the substantial presence test?
Students on F, J, M or Q visas and teachers or trainees on J or Q visas who substantially comply with their visa, foreign government-related individuals on A or G visas other than A-3 and G-5, and professional athletes in the US for a charitable sports event. Their days don't count, within time limits: students generally for 5 calendar years, teachers and trainees for 2 of the preceding 6.
Can I meet the test and still be treated as a nonresident?
Yes, in two ways. If you were here on fewer than 183 days this year, kept a tax home in a foreign country and had a closer connection to it, you can claim the closer connection exception by filing Form 8840. A tax treaty with a tie-breaker rule can also make you a resident of the other country for figuring US tax, claimed on Form 1040-NR with Form 8833.
Sources
- Substantial presence test, Internal Revenue Service, 2026
- Publication 519, U.S. Tax Guide for Aliens (2025), Internal Revenue Service, 2026
- 26 U.S. Code § 7701, Definitions, Legal Information Institute, Cornell Law School