The CreatorCon Call for Content is officially open! Get started here.

How to do date calculations inside a scoped app

gnewuser
Tera Contributor

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

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@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.

Thanks But I am going to make the change in clientscript and I get the following message : GlidDateTime is not defined.

@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.

AshishKM
Kilo Patron
Kilo Patron

Hi @gnewuser , 

 

Refer this thread, date difference calculated with clietn script and script include.

 

https://www.servicenow.com/community/itsm-forum/difference-between-2-dates-in-days-in-catalog-client...

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution