This question may be solved as follows:
Nearest Galaxy = Andromeda = 4.5 Light Years Away
1 Light Year = 6 Trillion Miles.
6,000,000,000,000 X 4.5 =
27,000,000,000,000 Miles.
The speed of an interplanetary space ship has not yet been determined because we don't have one in existance - working unit right now. However, for purposes of this discussion, we might use Escape Velocity and velocities of some of the recent probes that have been launched to distant targets in deep space. Those velocities are between
25,000 and 50,000 Miles Per Hour.
So:
27,000,000,000,000 divided by 25,000 =
1,080,000,000 Hours
1,080,000,000 hours divided by 24 hours in a day =
45,000,000 days
45,000,000 days divided by 365 Days in a Year =
1,233 years
Answer = 1,233 years traveling at 25,000 MPH.
and
Answer = 616 years traveling at 50,000 MPH.
(Note: No time allowance has been given for any swings around various planets to gain velocity by slingshot method.
The calculation presumes a line of sight flight, and is one way only, with no time spent orbiting various planets at the far end.)