
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2018 08:35 AM
What is the best way to do a breakdown based on 30 minute intervals? I know we can make an "Hour of day" bucket group to do things like identify the hour of day that an incident was opened. We have a need to get the half-hour increments of when records are created. Is this possible in a bucket group, or is there a better way to accomplish?
Solved! Go to Solution.
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2018 08:58 AM
I would create 48 buckets numbered 1-48 with names for each 30-minute block. Then a script like this should be able to translate the created time to the bucket:
var get30MinuteBucket = function (time)
{
var mSecs = time.getTime().getNumericValue();
var min = mSecs / (1000 * 60);
return Math.floor(min / 30);
};
get30MinuteBucket(current.sys_created_on);
Here is some code to test this:
// test code
var startTime = new GlideDateTime('2018-01-23 15:34');
var endTime = new GlideDateTime('2018-01-24 15:34');
while(startTime.compareTo(endTime) < 0)
{
gs.addInfoMessage(startTime + ' - ' + get30MinuteBucket(startTime));
startTime.addSeconds(60 * 43); // 43 minutes
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2018 08:58 AM
I would create 48 buckets numbered 1-48 with names for each 30-minute block. Then a script like this should be able to translate the created time to the bucket:
var get30MinuteBucket = function (time)
{
var mSecs = time.getTime().getNumericValue();
var min = mSecs / (1000 * 60);
return Math.floor(min / 30);
};
get30MinuteBucket(current.sys_created_on);
Here is some code to test this:
// test code
var startTime = new GlideDateTime('2018-01-23 15:34');
var endTime = new GlideDateTime('2018-01-24 15:34');
while(startTime.compareTo(endTime) < 0)
{
gs.addInfoMessage(startTime + ' - ' + get30MinuteBucket(startTime));
startTime.addSeconds(60 * 43); // 43 minutes
}