## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> CLOCK_OFFSET_AVG[CLOCK_OFFSET_AVG]:::quoted
CLOCK_OFFSET_AVG --> End((END))
```
## Purpose
The `CLOCK_OFFSET_AVG` SQL function gets the average number of milliseconds the system clock of the device where Invantive UniversalSQL runs is ahead of the clock on the Internet, as measured across the messages exchanged with the Invantive Cloud. The number is negative when the system clock is behind. The function can be used without parentheses.
The average is determined as follows: each response of the Invantive Cloud received during a message exchange contains the Internet clock time in UTC. Per response, the difference in milliseconds between the local system clock in UTC and the received Internet clock time is registered as a measurement. The average is the arithmetic mean of all measurements registered since the start of the process: the sum of the measured differences divided by the number of measurements. Contrary to the clock correction applied internally by the Invantive software, no limit is applied on the deviation.
See also [[CLOCK_OFFSET_LAST]], [[NOW]] and [[UTC]].
Returns: the average offset of the system clock in milliseconds as a number.
## Examples
The following example retrieves the average offset of the system clock in milliseconds; the actual value differs per device and invocation:
```sql
select clock_offset_avg
-------------------
125
```