Calculate duration according to a specific schedule
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 12:22 AM
Hello,
given 2 fields in project task table- "Planned end date" and "Planned start date" my task is to calculate the value of the field "duration" for a specific schedule. Is there a script or code segment that can help me achieve this?
Thanks in advance.
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 12:32 AM
@MikeMU You can use the subtract method to calculate duration between the planned start date and end date.
Here is the sample script.
var gdt1 = new GlideDateTime("2011-08-28 09:00:00");
var gdt2 = new GlideDateTime("2011-08-31 08:00:00");
var dur = GlideDateTime.subtract(gdt1, gdt2); // Difference between gdt1 and gdt2
gs.info(dur.getDisplayValue());
Here is the output
2 Days 23 Hours