- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 07:31 AM
I have a date field that I need to copy to a date time field. Is there a way to do this? Do I need to append the time before I copy?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 07:58 AM
You can copy it directly. By default it will end up with a midnight value on the date from the date field. Example:
var gr = new GlideRecord('table_name');
gr.get('SYS_ID');
gr.my_date_time = gr.getValue('my_date');
gr.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 07:58 AM
You can copy it directly. By default it will end up with a midnight value on the date from the date field. Example:
var gr = new GlideRecord('table_name');
gr.get('SYS_ID');
gr.my_date_time = gr.getValue('my_date');
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 08:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 08:09 AM
Hi Gaurav,
Be cautious when using getDisplayValue() on one side of your assignment. That output as the timezone applied. The database stores values in UTC so you've just introduced an offset error on line 8.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 08:19 AM
Thanks for the information Chuck. I checked that and you are right about it.