Double Tax Credit: Part year resident of both NY and NJ. Earned all income in NY. How to claim the tax credit for income earned and taxed by NY as well as NJ as resident?

I and my wife both were part year residents of NY for 212 days and moved to NJ. We  both earned income in NY all year. Our W2 shows income that we earned while we were residents of NJ along with NY income. Now in NJ state tax return, we can calculate the income that is double taxed ( NJ income reported on W2). How to calculate the tax that NY collected for the NJ portion of the income? What formula to use?