Ankur Bawiskar
Tera Patron

Hi Sourabh,



When you use dateDiff() method it has a third boolean parameter as true/false. True means give difference in seconds and false means give difference in duration i.e days hours min seconds



Use split method and the first position of the split array should give you the days



var date1 = new GlideDateTime();


var date2 = new GlideDateTime();


date1.setDisplayValueInternal('2014-01-01 12:00:00');


date2.setDisplayValueInternal('2014-01-03 13:00:00');



// Determine the difference as number of seconds (returns a string)


// Use getDisplayValue() to convert the string to the format expected by dateDiff()


var diff = gs.dateDiff(date1.getDisplayValue(), date2.getDisplayValue(), false);



var days = diff.split(" ")[0];


gs.print(days);



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur