- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 12:24 AM
Hi,
User is entering the date from record producer in dd-mm-yyyy format. In backend I want the fields to be in the YYYY-MM-DD 00:00:00Z format. How can I achieve this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 02:00 AM
in flow then convert that and send
Sample script to convert normal date/time to ISO format
var myDate = '2022-02-21 00:00:00';
var gdt = new GlideDateTime();
var dt = gdt.getValue().split(' ');
var f = dt[0].split('-');
var t = dt[1].split(':');
var event = new Date(f[0], f[1]-1, f[2], t[0], t[1], t[2]);
var isoDate = event.toISOString();
gs.info(isoDate);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 12:31 AM
Hi,
Go to Profile in instance and change the date format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 12:39 AM
Hi,
backend field is of type string?
you can convert dd-mm-yyyy to ISO format easily and store it using record producer script
how are you mapping it currently?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 01:00 AM
Hi Ankur ,
It is of Date/Time type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 01:05 AM
the format which is displayed depends on user's date format,
if target field is of date/time then why to convert?
You can directly map the date/time variable to that target field and it should work fine.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader