Tax ?, what happens if you move late in the year?

Hi,


I am somewhat familiar with taxes in Spain but not sure on this one.  We lived in Spain from 2010-2017 but I was on a foreign contractor visa.   I plan on moving with my family in the future on a golden visa, potentially in 2024.  My question is what happens as far as taxable income if you move to Spain late in the tax year?  School starts in September so most likely we would arrive in Aug to avoid the 183 days resident requirement.  However, I would hit the tax resident requirement of having my wife and kids living and going to school in Spain so I assume I will be considered a tax resident for 2024.  My question is is there a separation of taxable income on the dates prior to me arriving in Spain in the same tax year.  I would be cashing out a deferred comp plan in summer so will have a good salary from Jan to July prior to arrival in Spain.  However, I would have no earned income from Aug through Dec after arriving in Spain and only dividend income going forward.  My question is would I be held responsible for Spanish taxes (would be deep into the 47% range) on income earned in the USA prior to my arrival since it was earned in tax year 2024?  Any input is appreciated, thanks!