How to do date calculations inside a scoped app
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 08:48 AM
I have a scoped app with 2 date fields and an integer field on a form. I would like to find the difference between these 2 dates and populate the integer field with the difference which would be in days. Looks like I cannot use glidedatetime because this is client side.
How can I find the difference between 2 dates in terms of days in a scoped app.
Any help appreciated.
Thanks so much

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 08:53 AM
@gnewuser Your assumption is wrong, GlideDateTime is a server side API and available within scoped applications as well. You can verify this by visiting the official API documentation here https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server/no-namespace/c_GlideDateTim...
Please refer to this thread https://www.servicenow.com/community/developer-forum/calculate-the-dates-difference-in-days-in-scope... to calculate the difference.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 08:34 AM
Thanks But I am going to make the change in clientscript and I get the following message : GlidDateTime is not defined.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 08:43 AM
@gnewuser You will not be able to use GlideDateTime in client script. You can only use GlideDateTime inside a server side script e.g. a business rule or a script include. At client side java script Date() class is available to work with dates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 08:55 AM
Hi @gnewuser ,
Refer this thread, date difference calculated with clietn script and script include.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution