Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020
This article shows how to list work items by creation, change, resolution, or closed dates and how to use date macros (for example, @Today) and iteration macros for team sprints. For iteration path fundamentals and client/macro restrictions, see Query by area or iteration path.
Prerequisites
| Category | Requirements |
|---|---|
| Access levels | - To view and run shared queries: Project member. - To add and save a shared query: At least Basic access. |
| Permissions | Contribute permission set to Allow for the folder that you want to add a query to. By default, the Contributors group doesn't have this permission. |
Note
Users with Stakeholder access for a public project have full access to query features just like users with Basic access. For more information, see Stakeholder access quick reference.
| Category | Requirements |
|---|---|
| Access levels | - To view and run shared queries: Project member. - To add and save a shared query: At least Basic access. |
| Permissions | Contribute permission set to Allow for the folder that you want to add a query to. By default, the Contributors group doesn't have this permission. |
Supported operators and date macros
Use the following operators and macros for DateTime and Iteration Path fields in Query Editor.
- DateTime operators:
= , <> , > , < , >= , <= , =[Field], <>[Field], >[Field], <[Field], >=[Field], <=[Field], In, Not In, Was Ever - Date macros:
@StartOfDay,@StartOfWeek,@StartOfMonth,@StartOfYear,@Today
You can combine+/- nwith these macros (for example,@Today - 7). - Iteration macros:
@CurrentIterationand@CurrentIteration +/- n(see the following note and link for client restrictions and team-parameter behavior).
Note
Iteration macros and client restrictions are covered in detail on the iteration page: Query by area or iteration path. If you need queries to run in nonweb clients or via REST/WIQL outside the web UI, verify macro support in your environment and consider expanding macros to explicit paths.
Quick date examples (common queries)
Items created in the last 30 days:
Items modified on a specific date:
Items resolved today:
Items closed within a specified time period:
Items whose Closed Date is null (not closed):
Items whose status changed within the last week:
Using the @CurrentIteration macros (short guide)
Use @CurrentIteration to target the team's current sprint and @CurrentIteration +/- n to create a sliding window of sprints (for example, last two, current, and next two sprints). Important points:
@CurrentIterationreturns items assigned to the current sprint for the team context used when running the query.@CurrentIteration +/- nshifts that window of sprints by n; useful for trend or carry-over analyses.- Because macro behavior and client support vary, consult Query by area or iteration path for details about team parameters, which clients evaluate macros, and how macros are stored/expanded when saving queries.
Example images (web portal Query Editor):
Tip
If @CurrentIteration doesn't return expected results, confirm the team's selected iteration and the iteration date ranges in Team settings.
Date macros: start of day/week/month/year
Start-of macros help build consistent relative date ranges:
@StartOfDay,@StartOfWeek,@StartOfMonth,@StartOfYear— use these macros with+/- nto build ranges such as "since start of week" or "last 3 months."- These macros get evaluated by the web portal UI; their behavior in nonweb scenarios might differ—test in your target client.
Example queries:
When to use WIQL directly
Use WIQL when:
- You need advanced operators such as
WAS EVERfor Iteration Path changes. - Query Editor blocks or marks a clause as unsupported (for example, some
Was Everuses). The WIQL Editor extension lets you author those queries and save them.
See Work Item Query Language (WIQL) syntax and the WIQL Editor marketplace extension for examples.
Related content
- Query by area or iteration path
- Work Item Query Language (WIQL) syntax
- Query fields, operators, and macros
- Work item fields and attributes
REST API
To programmatically interact with queries, see one of these REST API resources: