Maximo Open Forum

 View Only

 How do I write a quarry to find p.m. work orders on or before current date?

  • Analytics
chris poe's profile image
chris poe posted 08-20-2025 11:52

I am trying to build a KPI to show any overdue p.m. work orders, but I cant figure out how to do on or before current date as apposed to a specific date in my where clause

this is the where clause select statement and error message all together for the kpi I need
system message
BMXAA2486W - The KPI could not be run successfully. Check the SELECT Statement and WHERE Clause for KPI. Invalid SQL queries are logged in the log file.
*select
select count(*) from workorder
where clause
where (schedfinish >= { > CURRENT DATE } and (woclass = 'WORKORDER' or woclass = 'ACTIVITY') and (status = 'APPR' or status = 'TRBT' or status = 'WPCOND' or status = 'HISTEDIT' or status = 'CRBT' or status = 'HBT' or status = 'INPRG' or status = 'RRBT' or status = 'WSBT' or status = 'WAPPR' or status = 'WMATL' or status = 'WSCH') and historyflag = 0 and siteid = 'HAL-NA' and istask = 0 and worktype = 'PM')
Christopher Winston's profile image
Christopher Winston

You are probably looking for something like

SQL Server:

((woclass = 'WORKORDER' or woclass = 'ACTIVITY') and historyflag = 0 and siteid = 'BEDFORD' and istask = 0 and pmnum is not null and targcompdate <= getdate() and worktype = 'PM')

Oracle: 

((woclass = 'WORKORDER' or woclass = 'ACTIVITY') and historyflag = 0 and siteid = 'BEDFORD' and istask = 0 and pmnum is not null and targcompdate <= SSYDATE and worktype = 'PM')

The pmnum is not null is if you are looking for those generated from pm records; worktype = 'PM' is if you want to use the worktype as the filter, and since I was not sure what you wanted, I included both. 

Victor Gonzalez's profile image
Victor Gonzalez

If you are using SQL Server, try schedfinish < getdate ()