Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

unable to format 07/24/2020 error in Tranform map

OluseyiS3924078
Tera Contributor

I have two date fields that i am mapping in my Tranform map

 

the source date field has the following format - mm/dd/yyyy <time>  there is no existing date format in ServiceNow that matches that.  Also i need it the instance format - yyyy-mm-dd<time>

 

Is there a way for me to change the format using a script, or will i have to do some manipulation in Notepad++?

6 REPLIES 6

lauri457
Tera Sage

GlideDateTime does this without any tricks required and it you can just use gr.setValue() on time field with these formats. You can also define the date format in the field map when the target field is a datetime field, even if someone has removed the suggestions for some reason you can just type it in.

 

GlideDateTime(String dateTime)

Instantiates a new GlideDateTime object using the passed-in date and time value.

The system attempts to match the passed-in value with the specified internal system format. If the argument does not match the system format, the system attempts to match it to one of the following formats in this order:

  • yyyy-MM-dd HH:mm:ss
  • MM/dd/yyyy HH:mm:ss
  • MM-dd-yyyy HH:mm:ss
  • MM-dd-yyyy HH:mm
  • MM-dd-yyyy
  • MM/dd/yyyy
  • dd-MM-yyyy HH:mm:ss
  • dd-MM-yyyy HH.mm.ss
  • dd-MM-yyyy HH.mm
  • dd-MM-yy HH.mm.ss
  • dd/MM/yyyy
  • dd-MM-yyyy
  • yyyy-MM-dd HH:mm
  • yyyy-MM-dd
  • dd.MM.yyyy HH:mm:ss
  • dd.MM.yyyy HH.mm.ss
  • dd.MM.yyyy hh:mm:ss a
  • dd.MM.yyyy hh.mm.ss a
  • dd.MM.yyyy

GlideDateTime | ServiceNow Developers

OluseyiS3924078
Tera Contributor

but what if the source field date format is  mm/dd/yyyy?

You specify the date format on the field map for the particular source field, see the attachment

Ankur Bawiskar
Tera Patron

@OluseyiS3924078 

you can set your date format in the field map for that date/time

You need not worry on the instance format.

Within the instance the format is shown as per user's date format.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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