I want to find the difference between the two date time fields and need to update in other duration field

venkataci
Kilo Contributor

I want to find the difference between the two date time fields and need to update in other duration field.

 

find_real_file.png   Log in Time and Logoff time are Date/ Time fields and Total Log time is duration field.

 

I have written server side script for this to work calling a glide ajax call. But it is not calculating the difference.

 

Client script:

find_real_file.png

 

 

Script include is:

 

find_real_file.png

 

Please help me to resolve it.

 

 

Thanks in Advance.

40 REPLIES 40

Dubz
Mega Sage

you can use the dateDiff() method to make the calculation:

 

 

var start = this.getParameter('sysparm_strt');
var end = this.getParameter('sysparm_end');
var duration = gs.dateDiff(start, end, false);
return duration;

dateDiff

venkataci
Kilo Contributor

Can u brief in some detail ..please

venkataci
Kilo Contributor

How can i pass this duration to Total Log time

just run that code in your script include and it should return the duration in days hours:minutes:seconds

 

durCalc: function(){
var start = this.getParameter('sysparm_strt');
var end = this.getParameter('sysparm_end');
var duration = gs.dateDiff(start, end, false);
return duration;		
}