Fetching records between two dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2019 01:37 PM
Hi ,
I am trying to fetch data based on two dates but not getting any results.
Can you update me where i am doing mistake or any option to fetch data.
where alert_bin_value and alert_app_value are alert's bin and application name.
var alert_created_1=gr.sys_created_on.getDisplayValue();
var dateTime = new GlideDateTime(alert_created_1);
dateTime.addSeconds(-1800);
var modifyAlertCreatedate=dateTime;
var inc1 = new GlideRecord("incident");
inc1.addEncodedQuery("assignment_group.name="+alert_bin_value+"^u_application.name="+alert_app_value+"^stateIN1,2,3^sys_created_onONLast 2 hours@javascript:gs.beginningOfLast2Hours()@javascript:gs.endOfLast2Hours()");
inc1.addQuery('sys_created_on','>',modifyAlertCreatedate);
inc1.addQuery('sys_created_on','<',alert_created_1);
inc1.orderByDesc('sys_created_on');
inc1.query();
Please help.
- Labels:
-
Field Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2019 12:17 AM
To me,, all incident and other date values visible in my timezone which is IST. So should I use both modifyAlertCreatedate and alert_created_1 in IST time zone to use in query or have to use in GMT timezone.
or
what timezone have to use for below queries.
inc1.addQuery('sys_created_on','>',modifyAlertCreatedate);
inc1.addQuery('sys_created_on','<',alert_created_1);
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2019 12:43 AM
Hi Anil,
To further assist you, kindly provide some more information on the actual data.
Print and share the values of these variables
modifyAlertCreatedate
alert_created_1
sys_created_on
Then add 1 condition and check if you are getting data or not.
inc1.addQuery('sys_created_on','>',modifyAlertCreatedate);
and as I understand you are using incident table. so have you created these custom fields in this table?
Also share the entire script here.