A dog that has good bladder control and has a good bladder can usually easily hold in urine for up to 8 hours but there's no guarantee.
Some dogs even though they can hold it for 8 hours may still urinate in the house while you're gone so you should put some pee pads on the floor for the dog in case they do urinate and keep them in one room while you're gone or crate them.
As for holding poop sometimes they can hold the poop for 8 hours but sometimes not.