# How Amplitude calculates session length

Source: https://amplitude.com/docs/data/sources/session-length

---

# How Amplitude calculates session length

Amplitude calculates session length via the following formula when session ID is used as the session property:

plaintext

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

Where:

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

Additionally, hidden, inactive, and deleted events will **not** be included in the session length calculation. For example, let's say you have the following series of events:

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), then the `max(client_event_time)` is taken from Event B instead of Event D.

Read more about how Amplitude tracks sessions in this [help center article](/docs/data/sources/instrument-track-sessions).

Was this helpful?

<!--$-->

<!--/$-->
