- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 02:21 PM
Hi,
I have a custom report created which shows the report sine the beginning. I want to modify this to show only last 6 months of data. Is there a way to do this? Please help me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2015 06:56 AM
If you are using SummaryTableWriter to query data, try using encoded string as below.
opened.setQuery("opened_at>javascript:gs.daysAgoEnd(30)");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 02:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 02:37 PM
Thank you Suraj for your reply. I am creating custom charts where we need to write queries. Here is the sample code which I use to query the data. I need help to filter only last 6 months data. I see that there is a gs function monthsAgo. Could anyone show me some insights on how to use this function?
var open = new GlideAggregate('change_request');
open.addQuery('u_incident_mim', '!=','');
open.addQuery('state', '!=','5');
open.addAggregate('COUNT');
open.addTrend('opened_at','Month');
open.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2015 02:55 PM
Hi,
You can add
open.addQuery('sys_created_on','>=', gs.monthsAgo(6));
Refer section 3.34.3 as an example.
GlideSystem Date and Time Functions - ServiceNow Wiki
Let me know if this helped.
Suraj Chauhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2015 05:48 AM
Hi - I am testing this out using the standard (oob) custom chart - Incident Backlog.
I am able to change the values to show by date i.e. by day rather than by month and I would also like to show this only for the last 30 days but no matter where I put the query
opened.addQuery('sys_created_on','>=', gs.monthsAgo(1));
it still hows the data from the start of our servicenow use.
Did anyone get this working ?