Get incidents between two dates using sys_created_on

dcherukuri
Kilo Explorer

Hi,

 

I was new to web service implementation for service now.I wanted to create a Encoded query to get records between two dates using sys_created_on.Please help me out

 

Thanks,

Deepthi.

5 REPLIES 5

anuj2
Kilo Explorer


Use below encoded query:



sys_created_onBETWEENjavasc#ipt:gs.dateGenerate('2014-09-01','00:00:00'#@javasc#ipt:gs.dateGenerate#'2014-09-10','23:59:59'#



Change the starting and ending.


Anurag Tripathi
Mega Patron
Mega Patron

hi Deepthi,



Here is the encoded query:



sys_created_onBETWEENjavascript:gs.dateGenerate('2014-08-01','00:00:00')@javascript:gs.dateGenerate('2014-09-05','23:59:59')



Make sure you are using the right date formats. If you have your dates in a different format then convert them in the format of the sys_created_on field. Let me know if you need help there.


-Anurag

Hi ,


I have a question the answer which you have given is using Glide System?currently am not using any glide system.So to perform date between operation, what i have to do?.I have no idea about Glide system.Can you please give me some other option on some info how to use Glide please.



Thanks,


Deepthi


Hi Deepthi,



I think this is what you want.



var a = gs.dateGenerate('2014-09-01','00:00:00');


var b = gs.dateGenerate('2014-09-06','23:59:59');


var str = "sys_created_onBETWEEN"+a+"@"+b;


var gr = new GlideRecord('incident');


gr.addEncodedQuery(str);


gr.query();


while(gr.next())


{


gs.print(gr.getValue('number'));


}



You can run this on any serverside object.


Try on a background script first.



Let me know if you have any further questions on this. Please mark the answer helpful/correct if it actually was


-Anurag