the equation works. however, you are doing it wrong.
(edit: looking back, you actually followed it correctly, except the fact that you converted it to degrees when you should of kept it as radians)
The equation
means A dot B, each divided by it's length, which is the same as normalizing them, so this is your equation:
dot_product(normalize(A),normalize(B))
, and then then take the arccosin, so: angle = arccosin(dot_product(normalize(A),normalize(B)))
.
this will still leave you with the problem of no difference between negative and positive, so you compare the angles.
so do something like this
I grabbed this image off discord since I'm not at pc; I hope it's good enough.
instead of tangent use whatever axis you want (the axis is: around what axis are you measuring the angle around)
simple answer
in truth there is already a node that does this in all 3 directions, and it's called align Euler to vector.
(you might have to do some extra steps to get it to work exactly as you want, though.)
Edit:
Here is a simpler way (removing unnecessary operations and nodes) of the image above:
or
here you don't have to normalize because the arctan2 does.
and if you to compare the angle and rotate it around a specific axis do this: