Client script to get 24 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 07:52 AM
Hi everyone,
I need to get "24 hours" ago in my client script. I'm actually trying to do a query to get all records from this person created within the past 24 hours. How do query for created_on to get everything created within a day ago?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 07:55 AM
I would do this using glideajax and then use one of the available server side date/time methods to do your query. Most of the time you're doing any querying or date/time work you want to do that on the server and then return the answer to the client script.
GlideDateTime - ServiceNow Wiki
GlideSystem Date and Time Functions - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 07:57 AM
Hi Eric,
I dont think you can do that in client side, But seeing your requirement i fee you anyways have to get to the server side to dig for the users
So here is a server side code that will help you to get this done.
GlideSystem Date and Time Functions - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 08:17 AM
Hi Eric,
i used this script to add seconds.
May be it is helpful some what and modify the script as per you.
var sla_date= 0.1669*24*60*60;
var now_time = gs.nowDateTime();
var gdt = new GlideDateTime(now_time);
gdt.addSeconds(sla_date);
gs.print("old_date :"+now_time);
gs.print("increaes_time:"+gdt.getValue());
Regards,
Harish.