- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 09:21 PM
Hi,
How do you convert duration to seconds in js.
Exporting duration to excel give the value in seconds. eg. 600
In Js, duration using obj.getDisplayvalue() gives me "10 min"
is there a obj.getseconds()? so it comes out in seconds - consistent with the excel export?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 10:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2017 02:55 PM
Thanks! This worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 03:16 AM
Hi Gowri,
I want to calculate the difference between two fields one is of duration type and other is a result of dateDiff(mean seconds).
using ur above code have converted duration to seconds but when i do date diff its resulting 0.
var execuitionTime='';
var totalKBExcution='';
var du='';
var kbExecutionTime=new GlideRecord('m2m_kb_task');
kbExecutionTime.addQuery('task.sys_id','2a8d087d13205700c5bdbd122244b0f8');
kbExecutionTime.query();
while(kbExecutionTime.next())
{
execuitionTime=gs.dateDiff(kbExecutionTime.sys_created_on, kbExecutionTime.task.resolved_at, true);
du=kbExecutionTime.kb_knowledge.u_execution_time;
var duration =du.getGlideObject().getNumericValue();
var durationSeconds = (duration/1000);
gs.print("Kb execution time in incident"+execuitionTime);
gs.print("Execution time in kb"+durationSeconds );
var totalKBExecution=gs.dateDiff(durationSeconds,execuitionTime,true);
gs.print(totalKBExecution);
}
Help me on this ASAP.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2018 11:09 PM
Hi Lavanya,
dateDiff is to calculate difference between dates, if you want to calculate difference between seconds which are already in numeric format, just use simple subtract operation:
var totalKBExecution=durationSeconds-execuitionTime;