new GlideDateTime().getMonth not working properly

gayatri6
Tera Contributor

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?

 

 

10 REPLIES 10

Simran4
Kilo Explorer

Hello,

Try with getDayofMonthUTC()  //return day from month  &  getMonth() //return month.

 

Thanks & Regards

 

Mark this Helpful

Prasad Pagar
Mega Sage

Hi,

Can you try 

gs.print(new GlideDateTime().getMonth());

in background script?

Are you in scoped app?

Thank you
Prasad

find_real_file.png

 

The result is :

*** Script: DAY=7
*** Script: MONTH =5

@gayatri

Did you check my below response to your comment?

I have shared sample script as well

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader