How to get use date in function field

samadam
Kilo Sage

I am using function field and want to get just the date difference. I used the following and it returns the hours/minutes etc.

glidefunction:datediff(now(), start_date)

what can I use to replace now () to just get the date?

11 REPLIES 11

I get this : 41 Days 18 Hours 44 Minutes

instead I want only 41 Days

 

try something like below code,

 

var v1 = new GlideRecord('your_table_name');

v1.query();

while(v1.next()){

var g1 = new GlideDate('start_date');

var g2 = new GlideDate(gs.now());

var sub = new GlideDate.subtract(g1,g2);

gs.info('Testing'+' '+sub.getDisplayValue());

}



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke