Muhammad bin Ishaq said: The Battle of Uhud took place in Shawwal, 3 AH, and the Battle of Khandaq in Shawwal, 5 AH. The Shaykh said: Regarding the Battle of Khandaq, the view of Urwah, Ibn Shihab and Malik bin Anas is that it took place in 4 AH. This is better than the view of whoever says that the Battle of Khandaq took place in 5 AH, because their view agrees with the hadith of Sayyiduna Ibn Umar (may Allah be pleased with them both). However, the scholars have tried to reconcile the two views: the Battle of Uhud took place two and a half years after the Hijrah and Khandaq four and a half years after it; whoever said four years meant after completing four years and before the fifth year had ended; and the one who said five years. Sayyiduna Ibn Umar's (may Allah be pleased with them both) saying "I was 14 years old" meant that he had entered his fourteenth year, and his saying regarding the Battle of Khandaq "I was 15 years old" meant that he had completed 15; but he did not mention the excess, because they understood it from the context and understood fifteen years without the excess. And Allah knows best.
And this is more correct in my view, because it has been reported that there were two years between Uhud and Khandaq.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحجر / 11306