- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2022 05:07 AM
Hi All,
I have tried adding the time to the DATE field using the below code, but i see that this is not working for me. Could anyone help me out if i was going wrong some where in the code.
CODE:
Here the lastlogin field type was DATE.
var date = current.last_login.getDisplayValue();
var time = "09:00:00";
var datetime = date + ' ' + time;
var gdt = new GlideDateTime();
gdt.setDisplayValue(datetime);
var dtstart = gdt.getValue();
var gdt2 = new GlideDateTime(gdt);
gdt2.addSeconds("3600");
var dtend = gdt2.getValue();
Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2022 08:10 AM
There are two field types available. Date and Date/Time.
If your field is of type Date, it won't take the time component.
Looks like you could configure an alternate field for the Date/Time use case.
If you can refactor the current field to a new field type, that might work - but you would have to be careful if you have content in the table (not even sure you can do the change if you have records).
If helpful or correct, please indicate so!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2022 08:10 AM
There are two field types available. Date and Date/Time.
If your field is of type Date, it won't take the time component.
Looks like you could configure an alternate field for the Date/Time use case.
If you can refactor the current field to a new field type, that might work - but you would have to be careful if you have content in the table (not even sure you can do the change if you have records).
If helpful or correct, please indicate so!