Get Day Part of datediff in Report Function Field

Aditya Raute
Mega Guru

I'm trying to create a report where I'm capturing the difference between a date field and sys_created_on which is a date/time field.

For function field, however, when I use datediff function I only want the Day part and not the hours, minutes and seconds part of the duration value.

I tried this:

 
 
 

glidefunction:datediff(submitted_at,sys_created_on).getDayPart()



and

 

glidefunction:datediff(submitted_at,sys_created_on.getDate())

 

However, neither are working and are returning empty values.

 

This should be possible right?

2 REPLIES 2

shivangi k
Kilo Sage

Hi @Aditya Raute ,

 

You can try a script similar to :

  var start = new GlideDateTime('current.submitted_at');
  var end = new GlideDateTime('current.sys_created_on');
  var diff = GlideDateTime.subtract(start, end);
  var days = diff.getRoundedDayPart();

  current.u_total_number_of_days = days;

 

Please mark helpful and accept solution if it helped you

this is in scripting

But we cannot use these functions in 'Function Fields' of a table