Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 02:29 AM
- Hi experts,
- I am Tring to insert the records from one table to another table in my personal instance, I have got struck with one of field called "Valid From" which is string type and value of the filed is 'August 22, 2022' and i have same filed called "valid from" in other table which is Date/Time type.
- here I need to know is there way i can convert the string "August 22, 2022" to Date/Time and update in filed.
- I have tried with below script but no luck.
- var vt = current.valid_from;
- var gdt1 = new GlideDateTime();
- var format1 = 'MM-dd-YYYY ';
- gdt1.setDisplayValue(vt + ' 23:59:59');
- var dt1 = new GlideDate();
- dt1.setValue(gdt1.getDate());
- var fr = dt1.getByFormat('dd-MM-YYY');
Thanks,
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 03:19 AM
yes you can convert
this will work
var vt = current.valid_from;
var gdt1 = new GlideDateTime();
var format1 = 'MMM dd, yyyy';
gdt1.setDisplayValue(vt + ' 23:59:59');
var dt1 = new GlideDate();
dt1.setValue(gdt1.getDate());
var fr = dt1.getValue();
gs.info(fr);
I tried the same in background script and it worked fine for me
Output:
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 03:19 AM
yes you can convert
this will work
var vt = current.valid_from;
var gdt1 = new GlideDateTime();
var format1 = 'MMM dd, yyyy';
gdt1.setDisplayValue(vt + ' 23:59:59');
var dt1 = new GlideDate();
dt1.setValue(gdt1.getDate());
var fr = dt1.getValue();
gs.info(fr);
I tried the same in background script and it worked fine for me
Output:
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader