Date and time operators

FuseQL date and time operators work with timestamps and query time boundaries, enabling time-based enrichment and filtering.

formatdate

Converts an epoch millisecond timestamp to a human-readable date string using a specified format pattern and optional timezone (default UTC). Use formatdate to produce readable timestamps for display, grouping by time period, or labeling output rows — for example, converting now() or a parsed epoch field to a date string for dashboards.

Syntax

| formatdate(<dateMilliseconds>) as <alias>

| formatdate(<dateMilliseconds>, <formatString>) as <alias>

| formatdate(<dateMilliseconds>, <formatString>, <timezoneString>) as <alias>
none

Parameters

Parameter Required Description

<dateMilliseconds>

Required

An epoch millisecond timestamp field or expression to format.

<formatString>

Optional

A date format pattern using Java DateTimeFormatter tokens (e.g. yyyy-MM-dd HH:mm:ss). Defaults to yyyy-MM-dd HH:mm:ss.

<timezoneString>

Optional

A timezone identifier such as UTC or America/Los_Angeles. Defaults to UTC.

<alias>

Required

Name for the resulting string field.

Example

Format the current time as a human-readable date string and return the first value per HTTP method.

source="nginx"
| parse "* - - [*] \"* *\" * * *" as ip,date,method,url,status,bytes,rest
| formatdate(now(), "yyyy-MM-dd HH:mm") as ts_str
| first(ts_str) by method
Expected output
method first(ts_str)

GET

2026-06-27 18:52

POST

2026-06-27 18:52

The exact output depends on the time the query runs. Common format tokens: yyyy (4-digit year), MM (month), dd (day), HH (24-hour), mm (minutes), ss (seconds), SSS (milliseconds), a (AM/PM). Use parsedate to convert a date string back to epoch milliseconds.

now

Returns the current epoch time in milliseconds at the moment the query executes. Use now() to compute time-relative expressions — for example, calculating how long ago an event occurred by subtracting a parsed timestamp from the current time.

Syntax

| now() as <alias>
none

Parameters

Parameter Required Description

(none)

now takes no arguments.

<alias>

Required

Name for the resulting millisecond epoch timestamp field.

Example

Capture the current time as a millisecond epoch value and convert it to a human-readable date string.

source="nginx"
| parse "* - - [*] \"* *\" * * *" as ip,date,method,url,status,bytes,rest
| now() as ts
| formatdate(ts, "yyyy-MM-dd HH:mm") as ts_str
| first(ts_str) by method
Expected output
method first(ts_str)

GET

2026-06-27 18:52

POST

2026-06-27 18:52

The raw millisecond value of now() from this query window was 1782586354919. The formatted string reflects the UTC timezone by default. Pair now() with querystarttime() or queryendtime() to compute offsets within the query window.

parsedate

Parses a date string using a specified format pattern and optional timezone (default UTC), and returns the corresponding epoch milliseconds as a long integer. Use parsedate to convert human-readable timestamps extracted from log fields into numeric epoch values for arithmetic, filtering, or comparison — for example, finding the earliest request timestamp in a window.

Syntax

| parsedate(<dateString>, <formatString>) as <alias>

| parsedate(<dateString>, <formatString>, <timezoneString>) as <alias>
none

Parameters

Parameter Required Description

<dateString>

Required

A string field or literal containing the date to parse.

<formatString>

Required

A date format pattern matching the input string, using Java DateTimeFormatter tokens (e.g. dd/MMM/yyyy:HH:mm:ss Z).

<timezoneString>

Optional

A timezone identifier such as UTC or America/Los_Angeles. Defaults to UTC.

<alias>

Required

Name for the resulting epoch millisecond field.

Example

Parse the nginx access log date field (format dd/MMM/yyyy:HH:mm:ss Z) into epoch milliseconds and return the earliest timestamp in the window.

source="nginx"
| parse "* - - [*] \"* *\" * * *" as ip,date,method,url,status,bytes,rest
| parsedate("dd/MMM/yyyy:HH:mm:ss Z", date) as ts_ms
| min(ts_ms) as earliest
Expected output
earliest

1782582780123

Values shown are illustrative; actual results depend on your log data and the selected time window. parsedate is the inverse of formatdate and uses the same format pattern tokens. A format mismatch between the pattern and the input string returns an error or null.

queryendtime

Returns the end time of the current query window as epoch milliseconds. Use queryendtime() to reference the boundary of the selected time range — for example, to compute the elapsed time between an event timestamp and the window end.

Syntax

| queryendtime() as <alias>
none

Parameters

Parameter Required Description

(none)

queryendtime takes no arguments.

<alias>

Required

Name for the resulting millisecond epoch timestamp field.

Example

Return the query window end time as both a raw epoch value and a formatted date string.

source="nginx"
| parse "* - - [*] \"* *\" * * *" as ip,date,method,url,status,bytes,rest
| queryendtime() as end_ts
| formatdate(end_ts, "yyyy-MM-dd HH:mm:ss") as end_str
| first(end_str) by method
Expected output
method first(end_str)

GET

2026-06-27 18:53:00

POST

2026-06-27 18:53:00

The raw millisecond value from this query window was 1782586380000. The value is fixed for the duration of the query and reflects the end of the user-selected time range. Use querytimerange() to get the total width of the window in milliseconds.

querystarttime

Returns the start time of the current query window as epoch milliseconds. Use querystarttime() to reference the beginning of the selected time range — for example, to filter events relative to the window start or to label output with the range boundaries.

Syntax

| querystarttime() as <alias>
none

Parameters

Parameter Required Description

(none)

querystarttime takes no arguments.

<alias>

Required

Name for the resulting millisecond epoch timestamp field.

Example

Return the query window start time as both a raw epoch value and a formatted date string.

source="nginx"
| parse "* - - [*] \"* *\" * * *" as ip,date,method,url,status,bytes,rest
| querystarttime() as start_ts
| formatdate(start_ts, "yyyy-MM-dd HH:mm:ss") as start_str
| first(start_str) by method
Expected output
method first(start_str)

GET

2026-06-27 17:53:00

POST

2026-06-27 17:53:00

The raw millisecond value from this query window was 1782582780000. The value is fixed for the duration of the query and reflects the start of the user-selected time range, not the time the query started executing.

querytimerange

Returns the total duration of the current query window in milliseconds. Use querytimerange() to scale per-window aggregations to a rate — for example, dividing an event count by the window duration to compute events per second regardless of the selected time range.

Syntax

| querytimerange() as <alias>
none

Parameters

Parameter Required Description

(none)

querytimerange takes no arguments.

<alias>

Required

Name for the resulting millisecond duration field.

Example

Compute the request rate (requests per second) for each HTTP method by dividing the count by the query window duration.

source="nginx"
| parse "* - - [*] \"* *\" * * *" as ip,date,method,url,status,bytes,rest
| count by method
| querytimerange() as window_ms
| eval((_count / window_ms) * 1000) as rps
Expected output
method _count rps

POST

2,159,649

599.9

GET

3,091

0.86

HEAD

183

0.05

The raw millisecond value from this query window was 3,600,000 (1 hour). Values shown are illustrative; actual results depend on your log data and selected time range.