Substantial Presence Test

To meet the Substantial Presence Test, you must be physically present in the United States on at least: 31 days during the current tax year you are asking about, and 183 days during the 3-year period that includes the year you are asking about, and the two prior years, counting:

The term United States includes the following areas:

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. However, there are exceptions to this rule for Canadian or Mexican residents that commute to the U.S. for work or foreign students, teachers and researchers, etc.

This information is found in Publication 519, U.S. Tax Guide for Aliens.