scheduled job to make active field false by comparing dates
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 02:20 AM
I need to create a schedule job for custom table which will run every day. The Schedule job will compare current datetime field with custom date field and if that date matches, make active false. I have written the code below. It is not working.
6 REPLIES 6

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 07:51 AM - edited 10-09-2023 07:54 AM
You just need to do the following to compare the dates:
var diff = gs.dateDiff(gs.nowDateTime(), gr.u_talent_pool_expiry_date, true);
if(diff < 0){ //checks if the date inserted has already expired
//do your logic here
}
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 08:44 AM
Hi Asif,
You can try this
var gr_inc = new GlideRecord('incident');
gr_inc.get('0488459f476135108b8dfa37536d434a');
var resolved = new GlideDateTime(gr_inc.resolved_at); //2023-10-09 22:37:31
var dateTest = new GlideDate();
dateTest.setDisplayValue(gr_inc.u_date_test); //2023-10-08
var duration1 = GlideDate.subtract(dateTest, resolved.getDate());
gs.print(duration1.getNumericValue()/(60*1000*60*24));
The result I got in the Background script