- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 03:39 PM
/* SCRIPT */
var gr = new GlideRecord('u_xyzTable');
gr.get('4d967a180fe70200b8de46a32050e20');
gs.print('u_a_date : ' + gr.u_a_date);
var newDateValue = new GlideDateTime('2014-04-07 08:17:00');
gr.u_a_date.setGlideDateTime(newDateValue);
gr.update();
gs.print('new u_a_date : ' + gr.u_a_date);
RESULT
[0:00:00.005] Script completed in scope global: script
*** Script: u_a_date : 2014-04-06 00:00:00
*** Script: new u_a_date : 2014-04-06 00:00:00
Is this a problem with the instance or is this a bug to be fixed?
Build name: HEAD (Fuji)
Build date: 09-03-2015_1003
Build tag: glide-fuji-12-23-2014__patch8-08-25-2015
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2016 04:40 PM
The answer to this issue is in the back-end. The description of the field is shown as date instead of datetime in the SQL table. ServiceNow UI shows it is in glide DateTime but on the back-end it is only date.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 05:47 PM
Try this instead
gr.u_a_date = newDateValue.getDisplayValue();
Is it definitely a Date/Time field, and not just Date?
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
‎02-17-2016 12:49 PM
Yes it works the same way the date is captured and the time zone difference is applied in hours but the minutes and seconds are reset to 00:00 still not saved properly as a complete date and time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2016 04:42 PM
I tested this against the OOB Date Time field 'Resolved' in glide-eureka-04-08-2014__patch11-hotfix2-07-08-2015 and could not reproduce the issue.
If u_a_date is definitely a DateTime field you should probably log a ticket with HI.
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
‎02-17-2016 07:01 PM
Also noticed that the date doesn't seem to be going in properly either.
You are putting in 2014-04-07 08:17:00
You are getting 2014-04-06 00:00:00
I think there is a business rule that is changing the value of the field.
Try this:
var gr = new GlideRecord('u_xyzTable');
gr.get('4d967a180fe70200b8de46a32050e20');
var newDateValue = new GlideDateTime('2014-04-07 08:17:00');
gs.print('newDateValue: ' +newDateValue.getDisplayValue());
gr.u_a_date = newDateValue.getDisplayValue();
gs.print('Before: ' + gr.u_a_date);
//gr.setWorkflow(false);
gr.update();
gs.print('After: ' + gr.u_a_date);
If your before and after are different, un comment line 7 and run the code again.
If this give you the correct after output, it means a business rule is messing with the field.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022