- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 10:42 PM
Hello Experts!
How do I extract or use the date from GlideDateTime()?
Thank you!
Carlo
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 10:50 PM
Please try,
var sdt = new GlideDateTime();
var dt = sdt.getDisplayValue().split(' ')[0];
gs.print(dt);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 10:50 PM
Please try,
var sdt = new GlideDateTime();
var dt = sdt.getDisplayValue().split(' ')[0];
gs.print(dt);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2022 06:35 AM
var rightnow = new GlideDateTime();
var rightnow_date = rightnow.getLocalDate();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2023 12:01 PM
This works better than the original answer. If you're running this as a user, gdt.getLocalDate() will give you a string of yyyy-mm-dd, whereas gdt.getDisplayValue().split(' ')[0]; will return it with the user's preferences, which may not be what you expected.
If you have to do a compare, using the yyyy-dd-mm string will let you compare greater than/less than comparisons directly on a string value, and get the result you expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 08:13 AM
var gdt = new GlideDateTime();
var dt = gdt.getDate();
gs.print(dt);
This would be more efficient as we can avoid using splits and typecasting