CityForZip()

<< Click to Display Table of Contents >>

Navigation:  Available Functions >

CityForZip()

Syntax

CityForZip( <CharacterValue>, <NumericValue> )

 

Purpose

Given a specific zip code, this function will return the name of the city associated with the zip code. Normally only one city is associated with a zip code, but if multiple cities are associated with the zip code, a specific associated zip code may be fetched by passing the number of the desired associated city as the second parameter. Passing zero for the second parameter will cause the CityForZip() to return the number of cities associated with the given zip code.

 

Parameters

<CharacterValue> may be the name of any character field, but is usually the Zip field. A character (alpha-numeric) field is used for zip codes since they may contain a dash.

 

<NumericValue> is an optional parameter which specifies which city to return for the given zip code (most zip codes have only one city associated with them). If omitted, the first city will be returned. If passed as zero, then a count of the number of cities associated with the given zip code will be returned.

 

Returns

The name of the city associated with the given zip code. Or, if <NumericValue> is zero, the number of cities associated with the given zip code.

 

Usage

This function can be used with custom selections. For example, a custom selection could be written to find all the constituents in a zip code bordering multiple cities, or dedicated to a single city.  

 

Example

The following examples illustrate various results of CityForZip():

 

CALL

RESULT

CityForZip( .Zip., 0 ) > 1

True if zip borders multiple cities.

CityForZip( .Zip., 0 ) = 1

True if zip contained within a single city.

CityForZip( "83864" )

Sandpoint

CityForZip( "83864", 0 )

1

CityForZip( "83864", 1 )

Sandpoint