i only worked 2 months as a subcontractor then was hired on to the company. I was still required to use my own vehicle to get to and from work. can i still deduct the mileage and expenses for the whole year?
Not quite, you would be self-employed as a subcontractor and report your business expenses on a Schedule C for two months.
After being hired on and getting a W-2 wage, you can no longer take the expense as a business expense, but now it would be treated as an employee unreimbursed expense. This would now be reported on a Schedule A itemized deduction, limited to the amounts above 2% of your AGI. The standard mileage rate for 2017 is $0.535.