I am trying to display the time taken to close the user story via WIQL query, but getting an error as incorrect query, can anyone please let me know how to to do.
Query:
SELECT
[System.Id],
[System.WorkItemType],
[System.Title],
[System.AssignedTo],
[System.State],
[System.Tags],
[Microsoft.VSTS.Common.ClosedDate]-[Microsoft.VSTS.Common.ActivatedDate] as TimeTaken
FROM workitems
WHERE
[System.TeamProject] = @project
AND [System.WorkItemType] <> ''
AND [System.State] <> ''
WIQL query is not SQL query, we cannot set the WIQL like this :
[Microsoft.VSTS.Common.ClosedDate]-[Microsoft.VSTS.Common.ActivatedDate] as TimeTakenPlease see Work Item Query Language (WIQL) syntax reference for details.
However, we can call the WIQL REST API (Query By Wiql) in a PowerShell script, then call Get Work Items REST API to retrieve the
ClosedDateandActivatedDateof each work item in a loop. Then calculate theTimeTakenusing New-TimeSpan utility.Below PowerShell for your reference: (We can also export the query results to a *.csv file and open it with Microsoft Excel to track.)