Why does GlideDateTime field not setting properly (sets the correct date but the time is set differently) using setGlideDateTime?

NYoks1
Giga Expert

/* 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

1 ACCEPTED SOLUTION

NYoks1
Giga Expert

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.


View solution in original post

8 REPLIES 8

The reason of the date difference is the time zone.   But we cannot identify the reason for the minutes and seconds not getting captured.   Already raised a HI ticket for this issue no resolution yet.


Were you able to run the provided code to see if any business rules were doing anything unusual?


Were before/after different?



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

NYoks1
Giga Expert

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.


So it was a Date field all along?



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022