scripting query Date field
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 02:59 AM
Hello Experts,
I am having query above the date field. how to apply the date filter with "at of after" condition.
var gdt = new GlideDate();
var date = gdt.getByFormat("yyyy-MM-dd");
gs.info('Todays Date ' + date);
var gdt1 = new GlideDateTime(date);
gdt1.addDaysUTC(-180);
var gdt2 = gdt1.getDate();
gs.info('ADD Date ' + gdt2);
var dgStart = gdt2;
gs.print(dgStart)
var noDuplicates= "035654444546d46df"
var gr=new GlideRecord('sys_user');
gr.addActiveQuery()
gr.addEncodedQuery('sys_idIN'+noDuplicates);
gr.addEncodedQuery('u_nowit_survey_date>='+dgStart) //// need help with this line of script.
gr.query()
while(gr.next()){
gs.print(gr.name);
}
How to check date is at or after dgstart.
Please help.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 04:21 AM
Hi,
it's always good to form the query in filter condition and then copy that as encoded query
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader