You can buy Sagrada Família tower tickets about 2 months ahead through the official website or app, as the Basilica's FAQ explains. You choose the Nativity or Passion tower during purchase. Your ticket name cannot be changed after purchase.
Every Sagrada Família ticket is valid only on the booked date and time. Bring the photo ID that matches your ticket, as the Basilica's rules require. Be at the entrance at your booked time. Late arrivals cannot enter the Sagrada Família.
The Basilica's opening-hours page lists the current hours: In October, the Basilica opens 9:00–19:00 Monday to Friday, 9:00–18:00 on Saturday and 10:30–19:00 on Sunday. The general entrance is on Carrer de la Marina, whichever tower you choose. Once you leave the grounds, your ticket does not allow you back in.
If your chosen tower has no slots, check the other side or another date. A tour is an alternative only when your selected option includes tower access.
Plan around: your booked entry time and the tower side available for your date.