Query for date 30 days from now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2013 09:05 AM
I am trying to schedule a job that checks for knowledge articles within 30 days of their "valid to" date and then generates an event if that is true.
'valid_to' is a glide_date field in a knowledge record. I'm having trouble getting the query right for retrieving knowledge recrods where the valid_to date is 30 days from the current date:
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('valid_to', '>=', gs.nowDateTime() + 30);
I know that's not the right syntax, but I'm not sure how to say the current date plus 30 days.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2013 09:37 AM
You could either use something different found in this document:
http://wiki.servicenow.com/index.php?title=Embedded:GS_Date_Time_Table
or for javascript you could do this:
var time = new Date();
newDate = time.setDate(d.getDate()+30);
gr.addQuery('valid_to', '>=', newDate);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2013 01:00 PM
From Jason's post:
http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#daysAgo.28int.29
Use the "daysAgo(int)"
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('valid_to', '>=', gs.daysAgo(-30));