How to convert number Into date?

SnowUserDev
Tera Contributor

Hi Community

 

As part of sccm output for last login timestamp field I am getting some 18 digit number instead of date. How can I convert this into date n set in the target field.

3 ACCEPTED SOLUTIONS

chetanb
Tera Guru

Hello @SnowUserDev 

 

var timestamp = current.your_timestamp_field;

// Convert the 18-digit timestamp to milliseconds

var timestampInMillis = parseInt(timestamp);

var gdt = new GlideDateTime();

gdt.setNumericValue(timestampInMillis);

var formattedDate = gdt.getDisplayValue();

current.formatted_date_field = formattedDate;

 

Please mark my answer correct or helpful if it solves your problem.

 

Regards,

CB

View solution in original post

Hi @SnowUserDev ,

 

You can try creating a script include in global scope & make sure to set the field applicable from All application scopes

& Paste the code over der. In ur transform map script u can call the script include like below:

 

new global.ScriptincludeName().function name(pass variable here which contains 18 digit value);

 

Thanks,

Danish

 

View solution in original post

6 REPLIES 6

Hi @Danish Bhairag2 @chetanb ,

 

The above script does not seem to be working in scoped application. Can u suggest an alternative or some workaround how can I get this running?

 

I have written this in robust transform map script section for the last login time field

Hi @SnowUserDev ,

 

You can try creating a script include in global scope & make sure to set the field applicable from All application scopes

& Paste the code over der. In ur transform map script u can call the script include like below:

 

new global.ScriptincludeName().function name(pass variable here which contains 18 digit value);

 

Thanks,

Danish