- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 09:18 PM
the expected output is 2005-01-31 but I'm getting 0036-06-27. how to resolve this?
Solved! Go to Solution.
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 11:17 PM
Hi Kukunooru,
Use the following in background script;
var gd = new GlideDateTime();
gd.setValue('31-03-2005');
gs.print(gd.getDate());
*** Script: 2005-03-31
Hopefully, this will resolve your query.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 09:28 PM
Can you try below
var gd = new GlideDate();
gd.setValue('2021-04-21');
gs.info(gd.getByFormat("yyyy-MM-dd"));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 10:06 PM
HELLO
PLEASE TRY THIS SCRIPT
var gd = new GlideDate();
gs.setValue('31-01-2005');
gs.print(gd.getByFormat('yyyy/MM/dd'));
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 10:16 PM
tried exact thing but I'm getting output as 2022/08/02
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 10:55 PM
Hello
sorry my bad there is a typo in my script .
ALSO IF YOU WANT TO DO IT BASED ON FIELDS YOU can try this
var sd = g_form.getValue("estimated_start_date_field_name");
var ed = g_form.getValue("estimated_end_date_field_name");
var startDate = new GlideDate(sd);
var endDate = new GlideDate(ed);
var dif = gs.dateDiff(startDate, endDate, false);
alert(dif)
Please mark my answer correct if it helps you
Mark this answer correct if it helps you