An angular problem-seems easy but is complex

In my game I have a ship that gets a 3d destination.
Now the ship needs to find the angle on yaxis that
it needs to get to to face the target. That’s good.
I figured out out that.

The x-angle gives me the problem though.
I need the destination to be rotated on Y axis
(in a temporary variable) so its’ y axis rotation value
becomes zero, so that when I check for the x angle
it won’t be rotated funny. Being rotated on the Y axis
in any direction would affect the xangle that I would
find, which is bad.

I have come to this solution but I think there
must be a better or easier way. Please post the
easiest way if you want.

** btw Z axis is not involved.

I find the angle on the y axis that it is
located in relation to the ship. Say that’s a 45
degree angle.
I then rotate it 270 degrees to bring it to zero.
That gets rid of anything that might affect the X angle.

I suppose that the problem comes all the way down
to the easiest way to rotate a 3d point.

I suppose this is a pretty long post for such
a seemingly small question, but if anybody thinks of an
idea I’d like to know of a easier way to do all this.