I need to select a range from 0 to 359.9 degrees in a SQL database.
My in put is in the form of a center angle and a range. For example center=100 range=50 would give me a range of angle>75 angle<125. However if center=0, then the range would be angle<25 and angle>335.
Thus my current algorithm works like this:
minangle = center-range/2
maxangle = center+range/2
if minangle<0, then minangle += 360
if maxangle>0, then maxangle -=360
Then in my query
if minangle<maxangle, I query angle>minangle AND angle<maxangle
if minangle>maxangle, I query angle>minangle OR angle<maxangle
This approach seems to be a bit convoluted. Is there a better approach?