Date Formatting - transform script

Priya123
Tera Contributor

2 questions

1) i need to check if the date coming thro import set is a Valid date ( not format but valid date by itself and not any string like N/a or tbd etc ) ?? there are couple of validations on the client side but something seems off in transform scripting when it comes to validation 

 

2) 3 columns with Date on the imported excel is in the Same format.. one column seems ok when loaded but other two columns when imported fails with unable to format .... Is there a way i can convert the date that comes through to a format and load to target table without asking business to change their sheets?? 

 

any leads on both? 

2 REPLIES 2

Abhay Kumar1
Giga Sage

@Priya123 DateTime format works in Servicenow same like Excel so either you keep same date format while importing from Excel or use string field in Servicenow.

But when you use string field , then you have to use GlideDatetime API and have to set display value so it will take same as user imported.

Hope this will help you.

Ankur Bawiskar
Tera Patron
Tera Patron

@Priya123 

you need to know what's a valid format you are expecting customer to share in that excel such as dd-MM-yyyy or dd/MM/yyyy

Unless you finalize a format for all the 3 excel columns it would be difficult for you to handle it in transform map

If you don't agree the format then it might be possible that after some days customer changes the format again. In that case your script or logic will break

If my response helped please mark it correct and close the thread so that it benefits future readers.

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