A Chapter 7 bankruptcy can be filed 8 years from a previous Chapter 7 filing. If your prior bankruptcy was a Chapter 13, you have to wait 6 years to file a Chapter 7. The time period runs from the beginning of the case, not the discharge date.
A Chapter 13 bankruptcy can be filed 4 years from a prior Chapter 7 filing or 2 years from a prior Chapter 13 filing.
As with anything, there are exceptions, especially for “repeat filers” and cases which were dismissed for abuse.