Calculate days between two dates in portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 04:15 AM
Hi,
I have requirement to display number of days between two dates in portal.
Example: Start Date :28-08-2023
End Date: 30-08-2023
No.of Days need display: 3
Please help.
Thanks,
Sowmya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 04:34 AM
Hello @Sowmya20 ,
you can use this server script to calculate days
var start = new GlideDateTime(''your_start_Date_field_name);
var end =new GlideDateTime('your_end_Date_field_name');
var dateDifferenceInMs =end.getNumericValue() - start.getNumericValue();
var dateDifferenceInDays = Math.floor(dateDifferenceInMs / (1000 * 60 * 60 * 24));
gs.info(dateDifferenceInDays);
Note :untested
Hope this helps
Mark the answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 04:41 AM
Hi Mohith,
Thank you for the replay. But I need display the answer in Service Portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 04:43 AM
@Sowmya20 is this in a catalog item ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 05:00 AM
Yes Mohith