The Substantial Presence Test: When a Visitor Becomes a US Tax Resident
How the 183-day test counts your US days over three years, which days are left out and how to find the date you became a resident alien for tax.

The Substantial Presence Test: When a Visitor Becomes a US Tax Resident
A foreign national can become a US tax resident without a green card simply by spending enough time in the country. Once that happens, worldwide income is taxed on Form 1040 rather than only US income on Form 1040-NR. The rule is the substantial presence test, and the counting is easy to get wrong. This guide explains it step by step with the Substantial Presence Test Calculator.
The two conditions
You meet the test for a calendar year if both are true:
- You were in the US on at least 31 days during that year.
- The weighted total reaches 183: every day this year, plus one third of the days last year, plus one sixth of the days the year before.
Any part of a day counts as a full day, so the day you land and the day you leave both count.
Worked example
Take a consultant who visits often:
- 10 February to 20 May 2024: 101 days.
- 5 January to 30 April 2025 and 1 September to 15 December 2025: 222 days.
- 10 January to 30 June 2026: 172 days.
The weighted total for 2026 is 172 + 222 ÷ 3 + 101 ÷ 6 = 172 + 74 + 16.83 = 262.83. Both conditions are met, so the consultant is a resident alien for 2026.
The calculator also finds the day the 183 mark is reached. The two earlier years contribute 90.83 weighted days, so 93 days in 2026 are needed. Counting from 10 January, the 93rd day present is 12 April 2026. Residency for the year normally starts on the first day of presence, not on that date, but the date shows how much room was left.
Days that do not count
Pub. 519 excludes several kinds of days:
- Exempt individuals. Students on F, J, M or Q visas, teachers and trainees on J or Q visas, and foreign government-related individuals. Students are usually exempt for five calendar years and teachers for two out of six. Each year needs a Form 8843.
- Transit. Less than 24 hours in the US between two foreign points.
- Medical condition. Days you could not leave because of a condition that arose while you were here.
- Commuters. Regular commuters from Canada or Mexico.
- Crew members of foreign vessels.
In the calculator you mark a stay as exempt and it is removed from every year. A student who arrived on 20 August 2025 and stayed through 2026, with the stay marked exempt, shows zero days and remains a nonresident.
The closer connection exception
Even if you meet the test, you can be treated as a nonresident for the year when all of these apply:
- You were present fewer than 183 days in the current year.
- Your tax home is in a foreign country.
- You have a closer connection to that country than to the US.
- You file Form 8840 by the due date of your return.
The consultant in the example had 172 days in 2026, so the exception could be available. Answering yes to the tax home question in the calculator changes the result to flag Form 8840. Ties that show a closer connection include where your permanent home, family, bank accounts, car, driving licence and voter registration are.
Treaties
Many income tax treaties have tie-breaker rules for people who are resident in both countries under their domestic laws. A treaty claim is made on Form 8833 and can change the outcome, though it does not change the counting.
Common mistakes
Counting only nights. The test counts any presence on a calendar day, so a same-day trip across the border counts.
Double counting trips from two records. Passport stamps and airline records often overlap. The calculator counts each calendar day once, so overlaps do not add days.
Forgetting the earlier years. Many people check only the current year and are surprised when 120 days a year for three years produces 180 weighted days (120 + 40 + 20), just short of 183. Add a few more days and the test is met.
Treating a student visa as permanent exemption. The five-year limit runs on calendar years, so a student entering in late August uses up a full year for those few months.
Missing Form 8840 or 8843. Both forms have deadlines, and a late Form 8840 can lose the exception.
Limits
The calculator counts days and applies the two conditions. It does not judge visa status, treaty positions or dual-status years, and it is not tax or immigration advice. Check Pub. 519, and use CBP's I-94 travel history to confirm your dates.



