• Log inStart now

NRQL: Group results across time

With NRQL, you can create queries that group results across time. For example, you can group results together based on timestamps by separating them into buckets that cover a specified range of dates and times.

When using time functions in NRQL queries, the results are returned in UTC. To adjust the results to your time zone, include the WITH TIMEZONE clause in your query.

Facet your NRQL query time range

To create your NRQL query, use a FACET clause with a bucket function that works with a timestamp attribute. Run a standard FACET query, but instead of faceting by an attribute, facet by time. For example:

SELECT count(*) FROM PageView SINCE 1 day ago FACET monthOf(account_created)

To perform multiple functions within the same query, use NRQL's multi-facet capability:

SELECT count(*) FROM PageView SINCE 1 day ago FACET dateOf(account_created), monthOf(account_created)

Time-based functions



Returns the year of a timestamp.


Returns the quarter of the year. The returned value includes both the quarter and the year.

Example: Q1 2014


Returns the month and year of the timestamp.

Example: July 2014


Returns the week the timestamp occurred by naming the month and day of that week's Monday.

Example: Week of January 15.


Returns the day of the week of the timestamp. The returned value loops back at the end of the week, allowing you to look at trends by weekday over time.


Returns the date of the timestamp. The returned value includes month, day and year.

Example: July 15, 2014


Returns the numeric date within a single month of the timestamp, a value from 1 to 31. The returned value does not include the month.


Returns the hour of the timestamp.

The returned value does not include a prepended 0 for hours between 1am and 9am. This differs from functions and clauses such as SINCE, which accept these hours with a 0 at the start.

Examples: 6:00, 12:00, 18:00

Copyright © 2023 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.