Using the warp factor to the third power warp scale, it would take the Enterprise over four years at warp six to get nine hundred light years from Earth, assuming near continuious straight line travel. Another indication that that scale by itself doesn't work. We see Trelane's planet moving at warp speed during the episode, so it at different times it could have been much closer to Earth. Given the planet's illumination in interstellar space, the planet's star (or the entire star system?) is accompanying the planet.