unixtime_microseconds_todatetime converts a Unix timestamp that is expressed in whole microseconds since 1970-01-01 00:00:00 UTC to an APL datetime value.

Use the function whenever you ingest data that stores time as epoch microseconds (for example, JSON logs from NGINX or metrics that follow the StatsD line protocol). Converting to datetime lets you bin, filter, and visualize events with the rest of your time-series data.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.

Usage

Syntax

unixtime_microseconds_todatetime(microseconds)

Parameters

NameTypeDescription
microsecondsint or longWhole microseconds since the Unix epoch. Fractional input is truncated.

Returns

A datetime value that represents the given epoch microseconds at UTC precision (1 microsecond).

Use case example

The HTTP access logs keep the timestamp as epoch microseconds and you want to convert the values to datetime.

Query

['sample-http-logs']
| extend epoch_microseconds = toint(datetime_diff('Microsecond', _time, datetime(1970-01-01)))
| extend datetime_standard = unixtime_microseconds_todatetime(epoch_microseconds)
| project _time, epoch_microseconds, datetime_standard

Run in Playground

Output

_timeepoch_microsecondsdatetime_standard
May 15, 12:09:221,747,303,7622025-05-15T10:09:22Z

This query converts the timestamp to epoch microseconds and then back to datetime for demonstration purposes.