What is the time test?
There are two tests you must meet in order to be entitled to deduct your job-related moving expenses. One of these tests is the so-called time test, which is also known as the 39 week or 78 week test. If, at your new job, you are an employee (as opposed to being self-employed or a partner in a partnership), the 39 week test applies, which means that you are only entitled to take a deduction for your moving expenses if you worked at your new location for at least 39 weeks in the twelve month period immediately following your move. The 39 weeks do not have to be consecutive and you do not have to work for the same employer the entire time. This means you can work at one job for 12 weeks, take a month off, and then work at a new job for 27 more weeks - as long as both jobs were within the 12 months after you moved (and in the same general location), you will have satisfied the time test.
The time test does not apply if you become disabled and, as a result, lose your job. In fact, if you lose your job for any reason other than quitting or being fired for willful misconduct, the 39 week test is waived. But if you resign or are discharged for willful misconduct, you need to find another job to fill the remaining weeks or you are not entitled to the moving expense deduction. Similarly, if you request a job transfer, the requirement is not waived. However, the time requirement is waived if your employer initiates a job transfer. Thus, if you moved from Los Angeles to Boston and ten weeks later your employer transfers you to New York, your expenses from Los Angeles to Boston are deductible even though you have not met the 39 week test. But if you requested the New York transfer, you cannot deduct the Los Angeles to Boston expenses.
If you are married and you and your spouse file jointly, only one of you needs to fulfill the 39 week requirement in order to deduct moving expenses. But you cannot add your times together (e.g., you worked for 12 weeks and your spouse worked for 30 weeks) - one of you must meet the requirement on your own. If you are married but you and your spouse file separately, you each may only claim your individual moving expenses if you each independently satisfy the time test.
As mentioned, the 39 week test only applies if you are an employee. If, instead, your are self-employed or a partner, the above all holds true, but the requirement changes to 78 weeks in 24 months instead of 39 weeks in 12 months (that is, you must have worked for 78 weeks in the 24 month period following your move).
The other test you must meet in order to be entitled to deduct your job-related moving expenses is the 50 mile distance test.