- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018 06:28 AM
Hello
Is it possible to have a formula that will auto calculate the minutes in each month. I have a formila indicator which needs to be:
Minutes per month - Outage down time
I have an indicator to calculate the outage down time per month but how can you script it to confirm the minutes per month. ie
June would be "43200 - Outage down time", but July would be "44640 - Outage down time" as June has 30 days and July has 31.
Solved! Go to Solution.
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018 08:39 AM
Try using a formula for this:
{{Number of open incidents}}
score_end.getDaysInMonth() * 1440
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018 06:31 AM
you can use the glide date time method getDaysInMonth()
var gdt = new GlideDateTime(); //December
gs.print(gdt.getDaysInMonth());
https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_GDT-getDaysInMonth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018 06:34 AM
Will this work? ie being in December would it show Novembers figures as 30 days still?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018 06:38 AM
I'm no expert with GlideDateTime so you might have to do some testing but you should be able to set the value of the gdt eg:
var dateTime = '2018-11-31 08:00:00';
var gdt = new GlideDateTime(dateTime);
gs.print(gdt.getDaysInMonth());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018 06:38 AM
The script I have at the moment is:
if ([[Indicator / By month SUM +]] > 0) {43920/[[Indicator / By month SUM +]]} else { 43920 }
Where "Indicator" is the name of the indicator I am getting the records from.