All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
It is permissible to buy the Udh-hiyah two weeks or more before the day of slaughtering (the day of Nahr). It is proven in authentic narrations that the Companions would buy and keep their sacrificial animals in Al-Madeenah to fatten them. This indicates that they would prepare such animals well in advance before the day of Nahr. We do not know that any scholar specified a certain time when the Udh-hiyah should be bought.
Allaah Knows best.