Usage of the .subtract() method
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 02:05 AM
What is the .subtract() method used for.
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 09:31 PM
Hi @atishaytoma
It used as below
subtract(GlideDateTime start, GlideDateTime end)
Returns the duration difference between two specified GlideDateTime objects.
Parameters
| Name | Type | Description |
|---|---|---|
| start | GlideDateTime | Start date object. |
| end | GlideDateTime | End date object. |
Returns
| Type | Description |
|---|---|
| GlideDuration | Duration difference between the two specified dates. |
Scoped equivalent:
To use the subtract() method in a scoped application, use the corresponding scoped method: subtract().
Example
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());
Output
2 Days 23 Hours
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2025 11:06 PM
How we can subtract the date, weeks, months, year from the current date?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 11:49 AM