This function allows you to calculate the distance in miles or kilometers between any two points on the earth. I created to calculate the distance between two zip codes but is can be used for any two coordinates for which latitude and longitude is known.
NOTE: A database for the coordinates of any US postal code can be obtained for free from Source Forge in CSV format. The URL is http://prdownloads.sourceforge.net/zips/zips.csv.zip?download
A short but interesting article, the author has figured out a way to create a PDF from a stored procedure without using a third party library.