Beginning preachers do well to preaching for 20 minutes. Some preachers or congregations have limitations that mean they should only have 20 minute sermons.
But as a basic rule of thumb, if you can't (or won't) preach for 40 minutes then don't bother.