DigitalFusion
03-03-2008, 09:56 PM
This is the query I am trying to run with an access database:
SELECT DealerName, DealerAddress, DealerState, DealerCity,DealerZip, ZIP_name, ZIP,DealerTollFreePhone, DealerPhone, Latitude, Longitude, ROUND((ACOS((SIN(45.412894/57.2958) * SIN(latitude/57.2958)) +(COS(45.412894/57.2958) * COS(latitude/57.2958) * COS(longitude/57.2958 - -92.633615/57.2958)))) * 3963) AS distance FROM Dealers INNER JOIN US_ZIP ON Dealers.DealerZIP = US_ZIP.ZIP
The problem I have is that Access does not have a ACOS function. So the following does not work:
ROUND((ACOS((SIN("&iStartLat&"/57.2958) * SIN(latitude/57.2958)) + (COS("&iStartLat&"/57.2958) * COS(latitude/57.2958) * COS(longitude/57.2958 - "&iStartLong&"/57.2958)))) * 3963) AS distance
I found a post from somewhere that said:
You can derive the ArcCos function using the following alternative: Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
My head starts hurting the second I even think about trying to convert that query with ACOS to this latter version.
SELECT DealerName, DealerAddress, DealerState, DealerCity,DealerZip, ZIP_name, ZIP,DealerTollFreePhone, DealerPhone, Latitude, Longitude, ROUND((ACOS((SIN(45.412894/57.2958) * SIN(latitude/57.2958)) +(COS(45.412894/57.2958) * COS(latitude/57.2958) * COS(longitude/57.2958 - -92.633615/57.2958)))) * 3963) AS distance FROM Dealers INNER JOIN US_ZIP ON Dealers.DealerZIP = US_ZIP.ZIP
The problem I have is that Access does not have a ACOS function. So the following does not work:
ROUND((ACOS((SIN("&iStartLat&"/57.2958) * SIN(latitude/57.2958)) + (COS("&iStartLat&"/57.2958) * COS(latitude/57.2958) * COS(longitude/57.2958 - "&iStartLong&"/57.2958)))) * 3963) AS distance
I found a post from somewhere that said:
You can derive the ArcCos function using the following alternative: Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
My head starts hurting the second I even think about trying to convert that query with ACOS to this latter version.