How to convert Long integer to Date/Time field type

sriram35
Kilo Guru

Hi,

 

I want to convert a long integer to Date/time. 

 

In LDAP I have a field called accountexpires. The field type is long Integer.

In the User table, I have field called End Date. The field type is Date/Time.

 

I want to map accountexpires with End Date.  

 

Can anyone help me?

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

if my answer helped you, kindly mark it as Correct & 👍Helpful so that it does not appear in unanswered list & close the thread.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Nikhil Phalke
Kilo Guru

Hi,

 

Please go through below link it might help you.

https://community.servicenow.com/community?id=community_question&sys_id=c616cb61db1cdbc01dcaf3231f96...

 

Please mark Helpful and Correct based on impact.

 

Regards

Nikhil

Jaspal Singh
Mega Patron
Mega Patron

Hi Sriram,

 

Can you try using below in the field map for the LDAP transform.

var gdt = new GlideDateTime();
gdt.subtract(gdt.getNumericValue());// gets the date to 0
gdt.add(source.yourintegerfield);// no quotes required
target.field_name=gdt.getDisplayValue();

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sriram,

Sample script below; ensure you use proper source and target fields

you can use this in your onBefore transform script

var dtUtil = new DateTimeUtils();
target.u_end_date = dtUtil.int8ToGlideDateTime(source.u_ad_date);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Mohammad Danis1
Giga Guru

Hi,

Yes, you can convert it, Please try below script :


var gdt = new DateTimeUtils();
target.field_name = gdt.int8ToGlideDateTime(source.field_name);

 

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_DateTimeUtilsAPI#r_D...

If my answer helped you in any way, please then mark it as helpful/correct.

Kind regards,