- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 09:27 PM
I am getting the wrong output after executing the below code.
var gr = new GlideRecord('x_408194_loading_e_scoped_data_table');
gr.query();
if(gr.next()) {
var gettDate = gr.date;
}
gs.info(gettDate);
var gd = new GlideDate();
gd.setValue(gettDate);
gs.info(gd.getByFormat('dd-mm-yyyy'));
Output
2022-04-22
22-00-2022
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 09:31 PM
Hi,
it works in scope
you have given the wrong format
update as this
var gr = new GlideRecord('x_408194_loading_e_scoped_data_table');
gr.query();
if(gr.next()) {
var gettDate = gr.date;
}
gs.info(gettDate);
var gd = new GlideDate();
gd.setValue(gettDate);
gs.info(gd.getByFormat('dd-MM-yyyy'));
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 09:31 PM
Hi,
it works in scope
you have given the wrong format
update as this
var gr = new GlideRecord('x_408194_loading_e_scoped_data_table');
gr.query();
if(gr.next()) {
var gettDate = gr.date;
}
gs.info(gettDate);
var gd = new GlideDate();
gd.setValue(gettDate);
gs.info(gd.getByFormat('dd-MM-yyyy'));
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 09:31 PM
Hi
getByFormat() works in scoped application. Example:
var gd = new GlideDate();
gd.setValue('2021-04-21');
gs.info(gd.getByFormat("YYYY-MMM-dd"));
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep