There is no one way of doing this. What you write is correct, but most people use the (IMO simpler) 3rd digit rule: the decade is decided by the third digit of the year. So 2020, 2021, ..., 2028, 2029 belong to the same decade, as do 2030, 2031, ..., 2038, 2039.
This indeed causes problems for the 1 - 9 AD decade, which only has 9 years this way, but most people won't care because we live in 2023.