"gr.getValue()" and "gr.getByFormat('hh:mm:ss')" return different times

PB7
Mega Guru
Hi Team,
 
I am drafting the below script to extract the HH:MM:SS from a date/time field for mapping to other fields ---
However, I'm seeing a 12-hour discrepancy. Please observe the attached snip [PFA-1].
Can anyone help me understand why there are two different times returned by '.getValue' and '.getByFormat' respectively? This is the target field[PFA-2].
 
 
var ct = new GlideRecord('u_coverage_tickets');
 
ct.addQuery('sys_id','004f3a4587c34154eaf041d8cebb3546'); //COT0001758
ct.query();
gs.log("CT-test " + ct.getRowCount());
 
if (ct.next()){
 
var gdt = new GlideDateTime(ct.u_previous_task_date);
 
gt = gdt.getTime();
gs.info("  value is " + gt.getValue()); //  *** Script: value is 1970-01-01 17:00:00
gs.info("  time is " + gt.getByFormat('hh:mm:ss')); // *** Script:   time is 05:00:00
}
6 REPLIES 6

Hi @PB7 

 

I’m not sure why getTime() is not working. Maybe your table is in a scoped app?

 

Alternate:

var ct = new GlideRecord('u_coverage_tickets');
 
ct.addQuery('sys_id','004f3a4587c34154eaf041d8cebb3546'); //COT0001758
ct.query();
gs.log("CT-test " + ct.getRowCount());
if (ct.next()){

gs.addInfoMessage((ct.u_previous_task_date.toString().split(‘ ‘))[1]);

}

 

Thanks!

 

Please mark this response as correct and helpful if it works 👍✔️

@PB7 

I can see you’re using gs.addInfoMessage on last line.

Try gs.info(gdt.getTime());

 

Thanks!

 

Please mark this response as correct and helpful if it works 👍✔️