# How Amplitude calculates session length

> For AI agents: a documentation index is available at [/docs/llms.txt](/docs/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

When you use session ID as the session property, Amplitude calculates session length with this formula:

```plaintext
*max(client\_event\_time) - min(client\_event\_time)*
```

In this formula:

- `client_event_time` is the local timestamp (UTC) when the device logged the event.
- `min(client_event_time)` is the local timestamp (UTC) of the first event logged by the device.
- `max(client_event_time)` is the local timestamp (UTC) of the last event logged by the device.

Amplitude excludes hidden, inactive, and deleted events from the session length calculation.

Example event sequence:

Event A --> Event B --> Event C --> Event D

If Event C and Event D are [hidden, inactive, or deleted](https://help.amplitude.com/hc/en-us/sections/16805649563163-Clean-up-your-data), Amplitude uses `max(client_event_time)` from Event B instead of Event D.

For more information about how Amplitude tracks sessions, refer to [Track sessions](https://amplitude.com/docs/data/sources/instrument-track-sessions).
