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.

How to use today's date in a sql statement's where clause? ​ I need to get data from a database based on today's date.

dharanikumar
Giga Guru

Hello All,

How to use today's date in a sql statement's where clause? ​ I need to get data from a database based on today's date.

Thanks!!

2 REPLIES 2

asifnoor
Kilo Patron

var gdt = new GlideDateTime();

var mydate = gdt.getDate();  

var gr = new GlideRecord('your_table');

gr.addQuery('your_field','STARTSWITH',mydate);

gr.query();

while(gr.next()){

// add your logic

}

 

Mark comment as correct if this answers.

Jeets
ServiceNow Employee
ServiceNow Employee
You need to use the date format which db understands, use timestamp instead of date. We recently found a known issue on use date()