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

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

AshishKM
Kilo Patron
Kilo Patron

Hi, 

Check the SCCM stage table and transform map for this filed, also check the same column data in sccm. This should not come as 18 digit number. 

-Thanks,

  • AshishKM

Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

SnowUserDev
Tera Contributor

@Danish Bhairag2 @chetanb 

 

I tried executing ur suggested script I'm background it is converting as desired. Thanks

 

@AshishKM there is one field from sccm which contains this values as 18 digit only.