- 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 11:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 10:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 10:21 PM
this is returning current date in expected format. I have set some date to gd in dd-mm-yyyy format then it is giving incorrect date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 10:24 PM
Hi,
the setValue() function in GlideDate always expects date in the internal format i.e. yyyy-MM-dd
So it won't work in the manner you are writing.
Already the value you are trying to get is in that format yyyy-MM-dd then what is your requirement?
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
08-01-2022 10:41 PM
Hi Ankur!
if I can't set dd-MM-YYYY by setValue(), is there anyway I can convert the dd-MM-YYYY to YYYY-MM-dd.
my actual requirement is to caluculate the duration. but the substract method is not working because of the format. I have tried multiple community solutions but no use. so I wanted to convert the dates to YYYY-mm-dd in client script so that I can get the duration.