Moscow and Kazan are well connected, with eight or nine trains every single day. The journey is a relatively swift 11 or 13 hours (depending on the train you choose), and most traverse the country in the evening. Only one direct train connects St. Petersburg and Kazan, a journey that takes 22 hours. Be aware that there are two stations in Kazan, but Kazan-2 is largely used for transit purposes.
We recommend you two convenient trains: №002Й (20:48 - 08:00) and №024M (23:08 - 10:45).
From St. Petersburg there is only one direct train a day which leaves from Moskovsky station (metro Pl. Vosstaniya). The journey takes approximately 22 hours and leaves St. Petersburg at 15:30 arriving in Kazan the next day at 13:58.