If in BKK you can do the day you arrive...outside of BKK check with your local immigration office to see what their policy is...cost is ฿1,900 for 30 days
If you’re in bkk you can do it 45 days out...if not in BKK check with the local immigration office to see what their policy is on extending visas...cost is ฿1,900