In the state tax return form, you can prorate your income and tax based on how long you worked/stayed there.