I need to filter for and specific date in a database view (OPENED AT >= 2017 - 01 - 01 )

luislembertsant
Kilo Expert

find_real_file.png

I need the where clause with 2 conditions :

1-     tsk_opened_at >= DATE('2017-01-01') but nothing happend.....

2-       (tsk_sys_class_name ='request' || tsk_sys_class_name ='incident' || tsk_sys_class_name ='catalog task' || tsk_sys_class_name ='external customer support' )

I have tried in differents way many times without any results.

Coud someone advice me ?

1 ACCEPTED SOLUTION

It seems you cant create a DB view with only one table, a workaround would be to add the task table a second time with prefix tsk2.


Then in tsk2 where clause set:



tsk_sys_id = tsk2_sys_id   && tsk_opened_at > '2017-01-01 08:00:00' &&


(tsk_sys_class_name ='sc_request' ||


tsk_sys_class_name ='incident' ||


tsk_sys_class_name ='sc_task' ||  


tsk_sys_class_name ='u_external_customer_support'




find_real_file.png



Also make sure you are using the table name, not the label, for example sc_request instead of Request



find_real_file.png


View solution in original post

18 REPLIES 18

antin_s
ServiceNow Employee
ServiceNow Employee

The below should work



tsk_inc_opened_at>='2017-01-01'



Hope this helps. Mark the answer as correct/helpful based on impact.



Thanks


Antin


Hi Antin,


I' getting wrong data:


find_real_file.png


antin_s
ServiceNow Employee
ServiceNow Employee

Sorry, it should be



tsk_opened_at>='2017-01-01'


Shiva Thomas
Kilo Sage

Hi Luis,



Try this one:


opened_at>=javascript:gs.dateGenerate('2017-01-01','00:00:00')



Here is the trick to generate perfect queries


Start by using the condition filter in the GUI for the target table and configure the exact query you need.


Capture d


Execute it, test your result, and use the contextual menu (right click) on the query itself to copy it for your code.


Capture d


This allowed me to generate the result above.