---
title: distance()
slug: distance
docTags: 
createdAt: 2021-09-14T17:46:03.000Z
---

Returns the distance between built-in addresses in ChartHop in the specified units.

### Syntax

`distance(point1, point2[, 'unit'])`

- `point1` - the first location from which to measure distance.
- `point2` - the destination to which the function measures distance.
- `unit` - (optional) the units of the returned distance.
  - Accepted values are: `meters` (default), `miles`, `km`.
- **Return type:** [Number](docId\:ucI5tCTfVBhonEJ6ZQijg)&#x20;

### Sample usage

`distance(address, workAddress, 'meters')` returns the distance in meters.

`distance(address, workAddress, 'miles')` returns the distance in miles.

### Supported data types

| **Input type**                                    | **Return type**                         | **Logic**                                                                                                                      |
| ------------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| ****[Address](docId\:cprKzR-VnOLXIXCms6UGz)  (x2) | [Number](docId\:ucI5tCTfVBhonEJ6ZQijg)  | If two Addresses are passed, the distance between the two will be returned in the specified units. Default units are `meters`. |
| *Unsupported data types*                          | **[Null](docId\:N9trVqonnBknqL9DrNBP6)  | Unsupported data types return `Null`.                                                                                          |

