8 hours is the longest that you should leave a dog in a crate but sometimes overnight you might be leaving your dog in the crate for 10 to 12 hours depending on how long you sleep.
But if you sleep for 12 hours you should always get your dog out of the crate as soon as possible after waking up and take them for a walk.
If you have to leave your dog alone in the house longer than 8 hours per day you should have someone come in and take care of the dog and take them out for walks.
Or if possible take the dog to a dog boarding place where they can take care of the dog while you're gone.