Query for getting last 6 month record

shid077
Tera Contributor

Query for getting last 6 month record from 'incident" table without using encoded query.

5 REPLIES 5

chetanb
Tera Guru

@shid077  please use below script

 

var increc = new GlideRecord('incident');
// last 6 months inc records
increc.addQuery('sys_created_on','>',gs.monthsAgo(6));
increc.query();
while(increc.next())
{
gs.info('Incident Number: ' + increc.getValue('number'));
gs.info('Total Incidents: ' +increc.getRowCount());
}

 

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Regards,

CB