Ran into this issue with a Store Locator that I'm building. The Radians function returns a Zero (0) when executing SELECT RADIANS(47), but it returns 0.83... when executing SELECT RADIANS(47.0).
The ending result is causing the distance calculated by the sql statement to be Zero (0). I'm running on the following system:
- OS Name Microsoft(R) Windows(R) Server 2003 Standard x64 Edition
- Version 5.2.3790 Service Pack 2 Build 3790
- System Model VMware Virtual Platform
- System Type x64-based PC
- SQL Server Microsoft SQL Server 2005
Here is the SQL statement that I'm using the radians function with.
SELECT TOP 15 i.* FROM (
SELECT [id],[storeName],[storeNumber],[latitude],[longitude],
ROUND((3959*acos(cos(radians([latitude])) * cos(radians( 47 ))
* cos(radians( -122.915 ) - radians([longitude])) + sin(radians([latitude]))
* sin(radians( 47 )))) , 2) AS distance
FROM [Public].[dbo].[stores] WHERE [latitude] <> 0 AND [longitude] <> 0
) i WHERE distance < '50' ORDER BY i.distance