unable to format 07/24/2020 error in Tranform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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++?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
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)
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:ssMM-dd-yyyy HH:mmMM-dd-yyyy- MM/dd/yyyy
dd-MM-yyyy HH:mm:ssdd-MM-yyyy HH.mm.ssdd-MM-yyyy HH.mmdd-MM-yy HH.mm.ssdd/MM/yyyydd-MM-yyyyyyyy-MM-dd HH:mmyyyy-MM-dddd.MM.yyyy HH:mm:ssdd.MM.yyyy HH.mm.ssdd.MM.yyyy hh:mm:ss add.MM.yyyy hh.mm.ss add.MM.yyyy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
but what if the source field date format is mm/dd/yyyy?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
