- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2020 07:00 AM
Hi Gurus,
Is it possible to retrieve data that has an updated date equal to Yesterday AND two days ago AND three days ago.
I see there are built-in options for today, yesterday, last 7 days etc, but that goes back to far. I just need for the past three days.
Let me know if you think this is possible.
Thanks,
Rob
Solved! Go to Solution.
- Labels:
-
Analytics and Reports

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2020 06:47 AM
try now
usrCount = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@3^u_unanswered_dateRELATIVEGT@dayofweek@ago@4');
usrCount.query();
var userArray = [];
while(usrCount.next()){
usrCount2 = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount2.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@2^u_unanswered_dateRELATIVEGT@dayofweek@ago@3^u_person=usrCount.u_person.name');
usrCount2.query();
while(usrCount2.next()){
gs.log('here1');
gs.log(usrCount2.u_person.name);
userArray.push(usrCount.sys_id.toString());
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2020 05:33 AM
Yes! Thank you! This this appears to work....
usrCount2.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@2^u_unanswered_dateRELATIVEGT@dayofweek@ago@3');
However, I do need one last thing added to the query, it needs to include a filter on the person_name that is found in a previous query(usrCount from script below)...
usrCount2.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@2^u_unanswered_dateRELATIVEGT@dayofweek@ago@3^u_person=usrCount.u_person.name');
here is the full script..the person field is taken from usrCount query then included in the userCount2 query, however nothing is return from the userCount2 query, i believe because the u_person=usrCount.u_person.name syntax is wrong.
usrCount = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@3^u_unanswered_dateRELATIVEGT@dayofweek@ago@4');
usrCount.query();
var userArray = [];
while(usrCount.next()){
usrCount2 = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount2.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@2^u_unanswered_dateRELATIVEGT@dayofweek@ago@3^u_person=usrCount.u_person.name');
gs.log('here1');
gs.log(usrCount2.u_person.name);
userArray.push(usrCount.sys_id.toString());
}
Thank you again!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2020 06:47 AM
try now
usrCount = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@3^u_unanswered_dateRELATIVEGT@dayofweek@ago@4');
usrCount.query();
var userArray = [];
while(usrCount.next()){
usrCount2 = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount2.addEncodedQuery('u_unanswered_dateRELATIVELT@dayofweek@ago@2^u_unanswered_dateRELATIVEGT@dayofweek@ago@3^u_person=usrCount.u_person.name');
usrCount2.query();
while(usrCount2.next()){
gs.log('here1');
gs.log(usrCount2.u_person.name);
userArray.push(usrCount.sys_id.toString());
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2020 01:16 PM
Yes Harshvardhan, that did solve the problem. Thank you so much for all your attention on this matter. I learned much, very appreciative. Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2020 12:20 PM
Hi,
I'm trying to isolate the results to just one day, for example i would like the records that were entered 3 days ago, only on that day. I think code that uses GT and LT logic may work, possibly what is below....
usrCount = new GlideRecord("sn_imt_quarantine_unanswered_health_status_user");
usrCount.addEncodedQuery('u_unanswered_dateRELATIVEGT@dayofweek@ago@4'^'u_unanswered_dateRELATIVELT@dayofweek@ago@3');
...do you think something like this may work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2020 08:58 PM
i have tested with below code, and this is giving me the correct result.
my testing scenario is like below.
I want list of incident which has created 3 days ago only. i mean today date is 14th so 3days ago would be 11th so i will only get 11th june incident record . this is dynamic just add the days in minus based on your need.
var gdt =new GlideDate();
gdt.addDays(-3); // here i am adding the days ago
var gr = new GlideRecord('incident');
gr.addEncodedQuery("sys_created_onON"+gdt+"@javascript:gs.dateGenerate('"+gdt+"','start')@javascript:gs.dateGenerate('"+gdt+"','end')");
gr.query();
while(gr.next()){
gs.print(gr.number);
}
if my answer helped you, kindly mark it as correct and helpful.