Query report to get requestid,username ,email with created date ( MSSQL )

Query report to get requestid,username ,email with created date ( MSSQL )

Tested in build MSSQL (14306)

SELECT wo.WORKORDERID AS "Request ID", aaau.FIRST_NAME AS "Requester", aaaci.emailid,wo."TITLE" AS "Subject", "cd"."CATEGORYNAME" AS "Category",
longtodate(wo.CREATEDTIME) AS "created time" FROM "WorkOrder" "wo" Left join AaaUser aaau ON wo.REQUESTERID=aaau.USER_ID LEFT JOIN aaausercontactinfo aaauci ON aaau.user_id=aaauci.user_id LEFT JOIN aaacontactinfo aaaci ON aaaci.contactinfo_id=aaauci.contactinfo_id LEFT JOIN sduser sdu ON sdu.userid=aaau.user_id LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN CategoryDefinition cd ON wos.CATEGORYID=cd.CATEGORYID  and wo.CREATEDTIME >= <from_lastmonth> AND wo.CREATEDTIME <= <to_lastmonth> ORDER BY 1

NOTE: Date filter highlighted in the query can be modified and below parameters can be used instead.

How to compare date column with auto filled date templates?
  1. Here is the example for getting this week data - CREATEDTIME >= <from_thisweek> AND CREATEDTIME <= <to_thisweek>
    • <from_thisweek> - Starting date of this week
    • <to_thisweek> - Ending date of this week
  2. Available Date Templates
    • Today - <from_today> - <to_today>
    • This week - <from_thisweek> - <to_thisweek>
    • Last week - <from_lastweek> - <to_lastweek>
    • This month - <from_thismonth> - <to_thismonth>
    • Last month - <from_lastmonth> - <to_lastmonth>
    • This quarter - <from_thisquarter> - <to_thisquarter>
    • Last quarter - <from_lastquarter> - <to_lastquarter>
    • Yesterday - <from_yesterday> - <to_yesterday>

Other format - (Date selection criteria is added)

SELECT wo.WORKORDERID AS "Request ID", aaau.FIRST_NAME AS "Requester", aaaci.emailid,wo."TITLE" AS "Subject", "cd"."CATEGORYNAME" AS "Category",
longtodate(wo.CREATEDTIME) AS "created time" FROM "WorkOrder" "wo" Left join AaaUser aaau ON wo.REQUESTERID=aaau.USER_ID LEFT JOIN aaausercontactinfo aaauci ON aaau.user_id=aaauci.user_id LEFT JOIN aaacontactinfo aaaci ON aaaci.contactinfo_id=aaauci.contactinfo_id LEFT JOIN sduser sdu ON sdu.userid=aaau.user_id LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN CategoryDefinition cd ON wos.CATEGORYID=cd.CATEGORYID where wo.CREATEDTIME >= datetolong('2021-04-20') AND wo.CREATEDTIME <= datetolong('2021-04-23')

PS : provide the needed dates in the bold area

      

                  New to ADSelfService Plus?