Manage Learn to apply best practices and optimize your operations.

# Zip Code Distance Calculation

I've developed a Formula language and LotusScript version of the formula to
calulate the distance between two zip codes in the US. The Formula language
version is included below.

There are several subscription zip code services available that will make
available a list of all valid zip codes in the country. You can arrange to
have the location of the zip code included in the file. The zip code itself is
great for validating data entry, but there are other ways to use the
information once it is 'in house'. To use this example:

1. Add the code below to a view action button in a database of zip codes.
2. Select one zip code in a view.
3. Click on the button and select a second zip code from the list.
4. See the distance between zip codes.

The script version has been great for calculating the closest vendor for a
company to work with and many similar applications.

Note: I have a small freely distributable DB of zip codes that I could include
with this example code to make it work out of the box.

Take a look and let me know what you think.
Andy
ziplist := @DbColumn("";"":"";"ZipCode";1);
zipToUse := @Prompt([OKCANCELLIST]; "Select a Zip Code"; "Select a zip code to
calculate distance from the selected zip."; "";ziplist);
zipRLat := @DbLookup("":"Cache" ; ""; "ZipCode"; zipToUse; "RadLatitude");
zipRLong := @DbLookup("":"Cache" ; ""; "ZipCode"; zipToUse; "RadLongitude");
zipCity := @DbLookup("":"Cache" ; ""; "ZipCode"; zipToUse; "City");
zipState := @DbLookup("":"Cache" ; ""; "ZipCode"; zipToUse; "State");

CalcX :=

RadDist := @ATan(-CalcX / @Sqrt(-CalcX * CalcX + 1)) + 2 * @ATan(1);
RndDistMI := @If(DistMi = 0;0;@Integer(DistMI * 10)/10);
@Prompt([OK];"Miles"; "Distance: " + @Text( RndDistMI) + " miles. From " +
City + ", " + State + " to " + zipCity + ", " + zipState + ".")
This was last published in November 2000

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

• ### Azure PowerShell cmdlets monitor, manage VMs

PowerShell gives administrators a way to customize reports that hone in on the details that matter to the business, such as the ...

• ### Windows out-of-band patches overshadow April Patch Tuesday

Microsoft delivered out-of-band security patches to address the Total Meltdown and malware engine exploits as a precursor to its ...

• ### Microsoft Project Honolulu shows promise but needs work

Microsoft Project Honolulu is still in the technical preview stage, but it needs to resolve a number of issues before it's a ...

## Search400

• ### iSeries tutorials

Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

• ### V6R1 upgrade planning checklist

When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

• ### Connecting multiple iSeries systems through DDM

Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

## SearchDataCenter

• ### Guide to buying server performance monitoring software

Integration, storage and vendor support all affect whether a performance monitoring tool is right for an organization. Mull over ...

• ### How IBM's data science team quickens users' AI projects

In this Q&A, IBM's Seth Dobrin discusses the rising user interest in machine learning and AI projects and the help inexperienced ...

• ### IBM blockchain technology spotlights mainframes

IBM's blockchain offerings aim to ease enterprise IT concerns by combining Z system mainframe hardware with industry-specific ...

## SearchExchange

• ### Cloud-based email security tools barricade entry to Exchange

The pressure is on Exchange administrators to avoid a ransomware outbreak that cripples the on-premises email system. Cloud-based...

• ### Migrating public folders requires extensive planning

Do your homework to find the right option for public folders when making a move to Exchange Online. Here are guidelines to help ...

• ### Using Microsoft Exchange certificates requires planning

Exchange certificates typically require minimal management effort after they have been set up, and they offer a secure means of ...

## SearchContentManagement

• ### Going paperless, AI, blockchain headline AIIM Conference

AI, cloud storage and blockchain technology were discussed at the AIIM Conference. The Pipeline podcast rehashes the conference ...

• ### How a digital transformation process helped curb reliance on paper

By moving on from paper, the North Carolina Court System and the Texas Animal Health Commission were able to accommodate ...

• ### Intelligent information management is ready for AI, blockchain

A panel discussion at AIIM 2018 looked at how AI, cloud and blockchain will disrupt the intelligent information management space.

Close