Train Travel Italy

I am holidaying in Italy in August. I have been onto the Trenitalia website looking to book from Salerno to Bari as well as Rome to Naples. How far out from my dates can you book?? I do not need to be on the fast trains!