Need to fetch records from a table which were created in last 30 seconds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 12:29 AM
Hi Folks,
Urgent help required.
I need to built a query which will fetch the records from a table which were created in last 30 seconds. Currently I'm able to fetch the records of last 1 minute.
Here is the code :
var query = "sys_created_onONLast minute@javascript:gs.minutesAgoStart(1)@javascript:gs.minutesAgoEnd(1)";
var Event = new GlideRecord('sysevent');
Event.addQuery(query);
Event.query();
I tried using "sys_created_onONLast minute@javascript:gs.minutesAgoStart(0.3)@javascript:gs.minutesAgoEnd(0.3)" for getting results of 30 secs but it did not work as expected.
Is there any SN function for seconds as we have for minutes.
Any suggestions would be appreciated.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 12:41 AM
Hi Karun,
I cant find any seconds function in glide system. But there is a funcion addseconds in glidedatetime which you can utilize.
You can add 30 seconds to the sys_created_on date and then compare the created date of record if it is equal or less than that and query.
Check if that works. You will have to modify your code.
One more approach could to use subtract function also given in the below link.
GlideDateTime - ServiceNow Wiki (section 3.68)
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 12:43 AM
Hi Karun,
I would do it by creating a GlideDateTime record "now - 30 seconds" then use this date in the query
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 12:53 AM
Interesting question. Can you provide a business use case where you need a resolution of 30 seconds?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 12:56 AM
The requirement is to have a dynamic event monitoring dashboard that will fetch the events triggered in last 30 seconds.