Get incidents between two dates using sys_created_on
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2014 05:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2014 06:04 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2014 06:10 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2014 12:12 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2014 02:15 AM
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