Did you move recently? You could get a tax deduction for moving expenses.

To write off your relocation costs, you must meet three tests:

  • Your move must be job-related.
  • You must meet a distance test.
  • You must pass a timing test.

As long as the other two requirements are met, it doesn’t matter if you’re moving for the first the job you’ve ever had, an existing job or to take a new job. A bonus: You don’t have to itemize expenses to take this deduction.

The distance test

The biggest moving hurdle, practically and tax-wise, is the 50-mile distance test. It’s designed to ensure your move isn’t just a way to ease your daily commute to work.

The location of your new job must be at least 50 miles farther from your previous residence than your last workplace was. That means if you lived 10 miles from your old job, your new job must be at least 60 miles from your old home before you can deduct moving costs. The distance test doesn’t take into account your new home’s location.

The IRS says you figure the distance using the shortest of the more commonly traveled routes. That means don’t take the scenic route to make sure you meet the mileage measurement.

Are you planning to move soon? Compare mortgage rates at Bankrate.

The timing test

The timing requirement has two components:

  1. To be deductible, moving expenses must be incurred within one year of starting at a new workplace.
  2. You must work full time at the new location for at least 39 weeks during your first 12 months there. The worked weeks don’t have to be consecutive or even with the same employer.

Don’t worry: You can deduct the expenses even if you have not yet met the timing tests by the time your tax return is due.

Self-employed workers moving to a new locale must meet the year-to-move deadline and work full time at their entrepreneurial enterprise for 78 weeks during the first 24 months. Again, the worked weeks don’t have to be consecutive.

Accounting for your moving costs

Once you meet the timing and distance requirements, gather your moving receipts.

IRS-approved deductions include the costs to move household goods and personal property, limited storage and insurance fees, and utility connection or disconnection charges.

Some lodging and travel expenses near your new and former homes also are deductible, as are shipping costs for your car. If you drove your car yourself, the standard mileage rate for using your vehicle to move in 2016 was 19 cents per mile. In 2017, the rate drops to 17 cents a mile.

You can also write off the travel arrangements you make to get your household pets to your new home.

A few other move considerations

  • If you’re married and file jointly, only one spouse needs to meet the time and distance tests. However, you cannot combine the weeks your spouse worked with the weeks you worked to satisfy the time-employed component.
  • If your new employer reimburses you for some or all of your transfer costs, don’t look to the IRS for additional help. Moving expenses paid by your boss aren’t deductible.
  • If you deduct moving expenses and then don’t pass the timing tests, you must file an amended tax return or include the moving expenses in your income the next year.

Details on moving expenses and tax deductions can be found in IRS Publication 521, Moving Expenses.

Is this the year for you to make a big move? Compare mortgage rates on Bankrate to find the best deal.