- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 10:42 PM
I am trying to set the field in yyyy-mm-dd format but it is giving me undefined value.
var date = "20.10.2018";
var dt = new GlideDate(date);
var dt3 = dt.getLocalDate().getByFormat("yyyy-MM-dd");
gs.print("Date :" + dt3);
Thanks in advance!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 10:53 PM
Try this
var date = "20.10.2018";
var dt = new GlideDateTime(date);
var dt3 = dt.getLocalDate().getByFormat("yyyy-MM-dd");
gs.print("Date :" + dt3);
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 10:53 PM
Try this
var date = "20.10.2018";
var dt = new GlideDateTime(date);
var dt3 = dt.getLocalDate().getByFormat("yyyy-MM-dd");
gs.print("Date :" + dt3);
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 05:49 AM
Thank you for the quick reply. It worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2022 11:56 PM
Hi Shwetha,
Do it like this
var date = "20.10.2018";
var dt = new GlideDateTime(date.toString());
var dt3 = dt.getLocalDate().getByFormat("yyyy-MM-dd");
gs.info("Date :" + dt3);
It should work.
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 05:50 AM
Hi,
I did try your code too. This is also correct.
Thanks for the help.