The Monday to Friday train service that leaves Pattaya around 2pm connects with the night sleeper service train to Chiang Mai in Bangkok with plenty of time to spare. You can buy tickets to any destination in Thailand in advance at any staffed station in Thailand. The fare to Bangkok is 31Baht and the night train to Chiang Mai with a bed is around 1000Baht. It's recommended to buy the sleeper train ticket in advance as those trains tend to sell out quickly.
You may think that the Pattaya to Bangkok train train takes around 4 hours, however it's saves faffaling about with taxis etc as the train will take you directly into Bangkok Hualapong station. Plus the it's nice scenery from the train, take as much luggage as you want. Much better than the bus, but being a train buff myself, I may be a bit biased.