I’ve recently moved from Spain to Switzerland, in November 2022. My question is if I have to pay the taxes for those 2 months of 2022 in Spain or in Switzerland.
Actually Switzerland has already been retaining taxes from my salary. So if I declare my Swiss salary in Spain I would be paying two times. I guess it may be some kind of double taxation agreement. In the case that I need to pay the taxes to Spain, how will I get back the taxes that Switzerland retained?
This is in general not true, and is in particular false in regards with Switzerland.
First of all, each country defines in its own law under what conditions one becomes a tax resident. This in total disregard of any others country’s legislation. In Switzerland this is defined in the Federal act on the federal tax and on the federal act on tax harmonization amongst the cantons. There you find, you are a Swiss tax resident from the date you formally declare your residency in Switzerland (by moving from abroad or birth in Switzerland) until you end it (by moving abroad, or by death). In absence of a formal residency registration you also become a tax resident when you work here for at least 30 days, or you spend at least 90 consecutive days in Switzerland.
Now, as this properly collides with other countries definition of tax residency, and thus potentially leads to double taxation, Switzerland concluded several bi-nationale treaties with many countries (but not with all). In most of those treaties it is defined that income from work, performed in one country is taxable in this country.
In conclusion: You have to look into the treaty with Spain, but most likely income from work performed in Switzerland is taxable in Switzerland. Note that “performed in” means, where you are physically located when you perform the work. If you do telework from Switzerland in Spain, the work is performed in Switzerland, not Spain.
I do (I am Spanish and Swiss) my annual declarations in Spain and here. As I am resident in Switzerland, I am taxed here for revenues -salary- but also pay a small amount for "wealth" in Spain due to our flat we still have there. Please don't take this as an official answer, a good approach is to ask to a tax accountant in Spain for those two months you lived/worked there, but for tax purposes, I guess you are considered as having your residence in CH.
Some countries (e.g. UK) have special rules on taxation if you leave mid-way through the tax year with the intention of being away for several years; meaning you only pay tax in your home country until the point you leave.
I.e. the 183 days may not apply in this case.
Hence my continued advice: ask a Spanish accountant!
I think you are wrong. I have just read the website of the Spanish tax office and they tax all the year if I lived more than 183 days in Spain, also the earnings from Switzerland. The only thing I can do is trying to get back the taxes I paid to Switzerland. But I don’t know how.
By the way, is necessary in Switzerland to make the tax declaration even if they already took my taxes every month and I didn’t have any kind of capital gains?
If the Spain-Switzerland double tax treaty follows the OECD format, than the income from work performed in Switzerland, while being a Swiss resident, is not taxable in Spain. It might have to be disclosed, as it could be relevant for the applicable tax rate. I linked to the treaties, read it (you can also search for the treaty on the relevant Spanish government website).
Als always: It depends.
If you had extra income, not subject to Swiss tax at source during your stay in Switzerland, and if this income is above the cantons threshold you must request a tax declaration. Threshold is anything between CHF 0 and CHF 3000 depending on canton.
If you have wealth above the cantons threshold you must request a tax declaration. Threshold is around CHF 80000.
If your income subject to Swiss tax at source, if extrapolated over 12 months, is above CHF 120k the tax office will send you a tax declaration.
I dont have to declare my Swiss income to the Australian tax office but I do have to declare all assets and income from Australia to the Swiss tax office.
For the year in question Spain will consider you as tax resident there, the whole year. If you now check the DTA ( https://www.boe.es/buscar/doc.php?id=BOE-A-1967-3470 ) as many times as required to understand which state is “this” and “the other” in each sentence, paragraph 2 of article 15 says that says that, being Spanish resident, the income you get from employment in Switzerland from a Swiss company (or a company with a permanent base in Switzerland) is not taxable in Spain.