is there a way to say that a product is only available until date x and then it's automatically disabled?

For example, training course A is on the 20th July, I want to offer places until the 18th July, on the 19th, the course is automatically disabled so that nobody else can buy a place on that course and that day can be used for preparing for the course next day.