Relative Time Operators in AQL

JFrog REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

AQL supports specifying time intervals for queries using relative time. In other words, the time interval for the query will always be relative to the time that the query is run, so you don't have to change or formulate the time period, in some other way, each time the query is run. For example, you may want to run a query over the last day, or for the time period up to two weeks ago.

Relative time is specified using the following two operators:

Operator

Description

$before

The query is run over complete period up to specified time.

$last

The query is run over period from the specified time until the query is run

Time periods are specified with a number and one of the following suffixes:

Time Period

Suffix

milliseconds

mills, ms

seconds

seconds, s

minutes

minutes

days

days, d

weeks

weeks, w

months

months, mo

years

years, y

For example, to specify five days, you could use 5d. To specify two weeks, you could use 2w.

Below are some examples using relative time operators:

//Find all the items that were modified during the last three days
items.find({"modified" : {"$last" : "3d"}})

 //Find all the builds that were created up to two weeks ago (i.e. no later than two weeks ago)
builds.find({"created" : {"$before" : "2w"}})