The faintest stars I can see in my 4-inch refractor are 12th magnitude. If one of these stars is just like the Sun, how far away is it?
The Sun would be magnitude 12.0 if it were 880 light-years away. That’s not very far in the grand scheme of the Milky Way Galaxy, which is nearly 100,000 light-years wide. Even if you had a 20-inch telescope and could see to 15th magnitude, you could detect the Sun only if it were as close as 3,500 light-years.
If you like playing with a calculator, here’s the formula. If the Sun were magnitude m, its distance d (in light-years) would be d = 32.6 √(2.512(m – 4.85)).
A handy rule of thumb says 5 magnitudes fainter means 10 times farther. In other words, if you know Capella shines at magnitude 0 from its distance of 42 light-years, it would shine at 5th magnitude from a distance of 420 light-years — and 10th magnitude from 4,200 light-years.
All of the above ignores “extinction,” or "dimming," of starlight caused by interstellar dust. But interstellar extinction is pretty negligible out to a thousand light-years or so in directions near the plane of the Milky Way, and much farther in directions away from the Milky Way.
— Alan M. MacRobert