One day in advance is normally plenty of time. If you're not sure, ask at a ticket window, or on the platform before boarding. Most night trains offer a few different sleeping options. You can usually sit in a regular seat all night for no reservation fee, but this can be uncomfortable. We recommend reserving a couchette.
Couchettes are bunks, with pillows and blankets provided.
They're a fun way to meet other travelers. Compartments with fewer people are sometimes available, but prices increase as the number of people decreases. You can reserve couchettes at most major train stations. Reserving two or three days in advance is usually plenty of time.