How long in advance can I book a Sri Lanka Railway ticket?
The tickets can only be booked not less than 35-37 days before the departure date depending on the route. Unfortunately, it is not (yet) possible to book closer to your travel date. You have to plan your trip for more than 4 weeks in advance.
Please note this rule does not apply to the Viceroy II by 12go carriages. Those tickets are available until they get sold out.