They know well in advance. When I went to a taping a few years ago, they handed audience members the date on a little postcard so you know when to tune in to the show you were at, though I guess that could always be pre-empted by unexpected circumstances.