Using a zipcode table with longitude and latitudes, here's a query to get the zipcodes and distances in a given radius of an origin zip code:


SELECT ZIP_CODE, (180/Pi() * (ACOS ((SIN(Pi()/180*#OriginLatitude#) * SIN(Pi()/180*Latitude)) + (COS(Pi()/180*#Attributes.OriginLatitude#) * COS(Pi()/180*Latitude) * COS(Pi()/180*ABS(#Attributes.OriginLongitude# - Longitude))))) * 69.11) AS Distance
FROM ZipCodes
WHERE (180/Pi() * (ACOS ((SIN(Pi()/180*#Attributes.OriginLatitude#) * SIN(Pi()/180*Latitude)) + (COS(Pi()/180*#Attributes.OriginLatitude#) * COS(Pi()/180*Latitude) * COS(Pi()/180*ABS(#Attributes.OriginLongitude# - Longitude))))) * 69.11) <= #Attributes.Radius#
ORDER BY Distance

Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Click Here

Reply via email to