new GlideDateTime().getMonth not working properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2021 11:55 PM
I need to get the current months of the 2 dates.
I am trying to use the getMonthLocalTime(), getMonthUTC() and getMonth() so as to get the current month of the date entered. If the date is larger than 12, then it is working fine and returning the month number. HOWEVER, if the date is less than 13, i.e., 1-12, then it is getting confused and returning the date of month number instead of the month number. What should I do?
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2021 12:04 AM
Hello,
Try with getDayofMonthUTC() //return day from month & getMonth() //return month.
Thanks & Regards
Mark this Helpful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2021 12:05 AM
Hi,
Can you try
gs.print(new GlideDateTime().getMonth());
in background script?
Are you in scoped app?
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2021 04:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2021 04:33 AM
@gayatri
Did you check my below response to your comment?
I have shared sample script as well
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader