how to calculate the days count between system date and current date in another field on item

Anuj30
Tera Contributor

We have a catalog item which required to fill a date in one field and then in another field days count need to be show .

for example user filled 25/03/2024

and my system date is 22/03.2024

then days count will appear 3 in days count.

Screenshot attached 

Please suggest how to achieve this 

 

Anuj30_0-1711102694175.png

 

6 REPLIES 6

Anubhav24
Mega Sage
Mega Sage

Hi @Anuj30 ,

Inside your script include after receiving the user entered date to get current system date time use below :

var gdt = new GlideDateTime(); 

and then you can use the difference method to calculate the difference between these two dates and get the day part.

Please mark correct/helpful if my response helped you.

JonnyFoster
Tera Contributor

Hi Anuj

 

Did you ever get this sorted? I have a very similar requirement. If you worked it out, please could you share?

 

Thanks

Jonny