- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-08-2022 09:12 AM
I have a requirement as below where need to check difference between two different type fields
field 1: duration field
field 2 : duration field
field 3: data/time field
Need to calculate below equation:
field_1 = difference (field_2 -field_3)
I am not able to find solution since not understanding how to convert duration field(field 2) to date/time for getting duration of field 1
I have written business rule for this.
var gtime = new GlideDateTime(current.field_3); // date/time field
var dur = new GlideDateTime(current.field_2); // not getting how to convert to date/time
var dur1 = GlideDateTime.subtract(gtime, dur); //the difference between gdt3 and gdt2
current.field_1 =dur1;
current.update();
please help me with above calculation.
Thanks in Advance..
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-11-2022 07:55 AM
Hi,
share this
var gtime = new GlideDateTime(current.field_3).getNumericValue();
var dur = current.field_2.dateNumericValue(); // this should give milliseconds value
current.field_1.setDateNumericValue(dur-gtime);
current.update();
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-10-2022 09:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-11-2022 07:55 AM
Hi,
share this
var gtime = new GlideDateTime(current.field_3).getNumericValue();
var dur = current.field_2.dateNumericValue(); // this should give milliseconds value
current.field_1.setDateNumericValue(dur-gtime);
current.update();
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-11-2022 10:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-11-2022 10:32 PM
Glad to know.
Please mark appropriate responses helpful as well.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader