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

HI AG

 

Will this work to get a difference in catalog field date to system date?

 

Yes, you need to capture System date in Variable and then do calculations. 

SP22
Giga Sage

Hi @Anuj30 ,

function setNumberOfDays() {
  var start = new GlideDateTime('current.u_start_date');
  var end = new GlideDateTime('current.u_end_date');
  var diff = GlideDateTime.subtract(start, end);
  var days = diff.getRoundedDayPart();

  current.u_days_count = days;
}

Thanks
SP