Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Database View where clause Date condition

almuhanm
Kilo Explorer

how I can add date condition for database view  

for example

some think like this :

opened_at > now() - 7   ( not working )

opened_at > now()   ( not working )

opened_at > Date() (not working )

opened_at > '2015-01031 06:11:55' ( working)

please see the attached screen

DatabaseView.jpg

3 REPLIES 3

Vimal Priya
Giga Guru

Hi Maha hamad,



Date() function to be used with some values like Date('2015-06-23')


And if you want to compare with current date use the function CURDATE()


now() is working well.



FYR,


1.JPG2.JPG3.JPG



Regards,


VimalPriya S


Darren Tan
Kilo Explorer

Hi Almuhanm,

 

Know this is a old thread. But wondering, were you able to get a solution to your problem since I am facing same issue also. The now() and CURDATE() does not seem to work in database view "where" clause.

 

Thanks!

 

Best regards,

 

Darren Tan

goscar79
Tera Contributor

Hi.

Use a Business Rule to add your query criteria. Here's the KB Article:

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0719186