How to return Date/Time field's value in milliseconds(epoch) in a business rule?

cc11
Tera Contributor

I am writing a business rule on incident table.

I want to print 'Created(sys_created_on)' field's value in milliseconds.

Looking for help.

Version - Jakarta

 

Thank you

1 ACCEPTED SOLUTION

Jon Barnes
Kilo Sage

you can get the number of ms since 1970-01-01 00:00:00 as an integer. is that what you are looking for?

var gdt = new GlideDateTime();
gdt.setValue(current.getValue('sys_created_on'));
var ms = gdt.getNumericValue();

 

View solution in original post

6 REPLIES 6

Jon Barnes
Kilo Sage

you can get the number of ms since 1970-01-01 00:00:00 as an integer. is that what you are looking for?

var gdt = new GlideDateTime();
gdt.setValue(current.getValue('sys_created_on'));
var ms = gdt.getNumericValue();

 

cc11
Tera Contributor

Yes!! Thank you very much!

I recently came across a better way of doing this that even works in scoped apps:

current.sys_created_on.dateNumericValue()

cc11
Tera Contributor

This is awesome! Short and simple and it works!

Thank you to both of you!