You can book your train ticket up to 30 days in advance. However, the exact booking window may vary depending on the length of the train trip for Thai Railways.