- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 06:11 AM
Good morning everyone,
I cannot for the life of me figure out how to convert a string date of dd-MMM-yy(01-Jan-16) to a GlideDate standard format of yyyy-mm-dd 2016-01-16. For whatever reason, having the month in the simpledate string throws the conversion off. Anyone have any suggestions because I am wreaking my brain over here . I have read all of the wikis and may I have missed something so I apologize in advance if this has already been addressed.
Thanks in advance
Ernie
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 06:43 AM
Hi Ernest,
You should be able to do this with GlideDate(). I tried this in a background script and it worked.
var gdt = new GlideDate();
gdt.setValueUTC("01-Jan-16", "dd-MMM-yy");
gs.print(gdt.getValue());
GlideDateTime - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 06:40 AM
Hi Ernest,
following script (server side) works fine on my instance (Fuji version):
var tt = '10-Feb-12';
var nt = new GlideDateTime();
nt.setDisplayValue(tt, 'dd-MMM-yy');
gs.print("time is:" + nt.getDisplayValue());
output is: time is:2012-02-10 00:00:00
Hope I have understood your issue correct...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 07:06 AM
Hey epam
Thanks for your response,
I am simply testing this in a scheduled job and outputting the result to the log and I get an error that 10-Feb-12 is an unparseable date.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 06:43 AM
Hi Ernest,
You should be able to do this with GlideDate(). I tried this in a background script and it worked.
var gdt = new GlideDate();
gdt.setValueUTC("01-Jan-16", "dd-MMM-yy");
gs.print(gdt.getValue());
GlideDateTime - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2016 07:15 AM
This is exactly what I was looking for. Thank you so much Brad. Dates is one thing I would like to outsource