How to remove time from Date and time while importing field in servicenow

mahesh105
Tera Contributor

I am importing Data from excel using import set. While importing I have Date field in excel which has format dd/mm/yyyy tt:mm. but I want to import only dd/mm/yyyy and not tt/mm. How to achieve that without editing excel in servicenow and without configuring dictonary.

1 ACCEPTED SOLUTION

Sagar Pagar
Tera Patron

Hi,

You can try this script in transform map scripts -

 

var excel_date = source.u_date_field.toString();

var today = new GlideDateTime(excel_date);

target.u_date = today.getDate();

 

 

Feel free to mark helpful & correct!

Thanks,

Sagar Pagar

The world works with ServiceNow

View solution in original post

2 REPLIES 2

Mark Manders
Mega Patron

If you set the 'date format' field on the field mapping correctly (as it is in excel), it should transfer to your date field without any issue.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Sagar Pagar
Tera Patron

Hi,

You can try this script in transform map scripts -

 

var excel_date = source.u_date_field.toString();

var today = new GlideDateTime(excel_date);

target.u_date = today.getDate();

 

 

Feel free to mark helpful & correct!

Thanks,

Sagar Pagar

The world works with ServiceNow