Quantcast
Channel: ServiceNow Community - Development & Integration
Viewing all articles
Browse latest Browse all 423

Get Most Recent Date in Query

$
0
0

Hello,

I am trying to write a query to pull back the most recent date (MAX) from a table. The query is not working.

What is the way to query to give you the most recent date value (sys_created_on)?

var count =new GlideAggregate('kb_use');
count.addQuery('article','10a274a9048599009433ce3847235f89');
count.addQuery('used',true);
count.addAggregate('MAX','sys_created_on');
var max = 0;
while(count.next()){  
  gs.print('next: '+ count.sys_created_on);
    max = count.getAggregate('MAX','sys_created_on');
 
}
gs.print("MAX Date: "+ max);

Thanks!


Viewing all articles
Browse latest Browse all 423