converting string to GlideDateTime
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2015 04:35 PM
Hi - hopefully someone has encountered this before and can get me over the last hurdle. I am importing records from excel into SN using a transform map. A few fields are date fields or which i have made strings - then during the transform i convert to glidedateTime. The transform reports ignored errors and the dates populate in the target but the HHMMSS do not convert but default to midnight. I need to keep as date time and in dd-mmm-yyyy hh:mm:ss format. My transform script is onBefore:
var gdt = new GlideDateTime();
gdt = source.uclosed;
target.u_closed = get + get.addDays(+1);
I have to add one day to match the source date.
Any help is appreciated.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2015 05:33 PM
Have you tried this
var gdt =new GlideDateTime(source.u_closed);
gdt.addDays(1);
target.u_closed = gdt;
You should be able to find the methods you need on the wiki page
GlideDateTime - ServiceNow Wiki
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2015 07:26 AM
Thank you Paul! I see my error in the script - this worked along with
changing the date format in the field map of the source date field. So now
the transform works without an error but still the hours minutes and
seconds default to midnight. Do you know of a wiki article that addresses
this or have an idea? I really appreciate your insight!
On Thu, Jul 16, 2015 at 8:33 PM, Paul Morris <

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2015 08:30 PM
Your string has to be in the following format
- value - (String) A UTC date and time using the internal format yyyy-MM-dd HH:mm:ss.
If it is in this format it should account for the HH:mm:ss if you are using the constructor below
var gdt =new GlideDateTime("2011-01-01 12:00:00");
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2015 11:15 PM