Converting from LDAP Active Directory Filetime format into glide.DateTime?

mcrib
Mega Expert

Trying to convert from an LDAP import using a transform into a ServiceNow DateTime field. Doing so if in "UNIX time" is easy using setNumericValue, but this doesnt work on AD "Filetime" 18-digit formatting.   Has anyone run into this before and been able to transform? I don't see a built-in function in SN and looking on the web hasn't yieled anything either.

Thanks.

1 ACCEPTED SOLUTION

mcrib
Mega Expert

Well I figured it out.. if anyone has the same issue in the future here's the answer (can be pasted into Scripts - BG.. you'll need to convert it a bit for the field variables on the transform script):



var gdt = new GlideDateTime();


var mstime = (130997660145165200);


gdt.setNumericValue((mstime - 116444736000000000)/10000);


gs.print(gdt.getValue());


gs.print(gdt.getNumericValue());


View solution in original post

5 REPLIES 5

Patrick DeCarl1
ServiceNow Employee
ServiceNow Employee

Can you share an ex of the filetime?


Sure. AD has it listed as 130997660145165200 in one example, which should translate to 2016-02-12 15:53:35 GMT in YYYY-MM-DD format


mcrib
Mega Expert

I should also mention that Filetime is the intervals of 100-nano seconds since JAN 01 1601


mcrib
Mega Expert

Well I figured it out.. if anyone has the same issue in the future here's the answer (can be pasted into Scripts - BG.. you'll need to convert it a bit for the field variables on the transform script):



var gdt = new GlideDateTime();


var mstime = (130997660145165200);


gdt.setNumericValue((mstime - 116444736000000000)/10000);


gs.print(gdt.getValue());


gs.print(gdt.getNumericValue());