Brian Dunning's FileMaker Custom Functions

DistanceBetweenPoints ( Lat1 ; Lon1 ; Lat2 ; Lon2 ; Units )

Calculates the distance between any two points on Earth.

  Average rating: 4.1 (48 votes) Log in to vote

Vaughan Bromfield   Vaughan Bromfield

Share on Facebook Share on Twitter

  Sample input:
DistanceBetweenPoints ( 0.592539; 2.066470; 0.709186; 1.287762; "nm" )
  Sample output:

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Based on "Aviation Formulary v1.42" by Ed Williams <>.

Calculates the distance between two points on Earth (assuming earth's radius is 6366.71 km) based on the second "Great Circle Distance Between Points" formula that proports to give less rounding error for short distances.

Since FMP's formula dictionary does not contain asin, the distance formula is modified to use atan as described in the "Implementation Notes". The format of the custom function below attempts to make these original formulae explicit.

Latitude and Longitude are entered in decimal degrees.

The Units variable accepts "radians", "nm", "km" and "miles". Empty latitude, longitude variables, or unrecognised units entries cause the function to return "?".



NA   NA, Oz
Mar 22, 2009
How do I use this correctly?

I have copied into Custom Functions but get an error "The specified parameter cannot be found" Lat1 is highlighted.

Any ideas?
Vaughan Bromfield   Vaughan Bromfield
Jun 3, 2009
It works for me...

All I can suggest is that you make sure you add "Lat1" and the other parameters to the second panel in the custom function dialog.
Eric   Eric, SJSU
Jun 9, 2009
I can't get the sample input to give me the sample output. What is the order of the parameters in the function definition?
Vaughan Bromfield   Vaughan Bromfield
Jun 21, 2009
The sample input should be:

DistanceBetweenPoints ( 0.592539; 2.066470; 0.709186; 1.287762; "nm" )
Vaughan Bromfield   Vaughan Bromfield
Jun 21, 2009
My bad, the data in the sample is incorrect. I have quoted lats and lons in radians and it should be in decimal degrees.

Enter this data into the CF:

Lat1 = 33 + (57/60) ;
Lon1 = 118 + (24/60) ;
Lat2 = 40 + (38/60) ;
Lon2 = 73 + (47/60) ;

... and the result is 2143.7261012545210023.

Log in to post comments.


Note: these functions are not guaranteed or supported by Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.