- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2019 08:52 AM
How can I get the current month of the system date as a value, for example if current month is January then return 1, April return 4, etc...
I have a select box field variable on my catalog item called Month, with 12 choice questions create for user to pick from, these question choices are January - December with value 1 -12 correspondingly. I want to set the default value using javascript,
I had tried the following scripts in the default value field:
javascript: gs.getMonthLocalTime();
javascript:gs.nowDateTime(m);
javascript: var gdt = new GlideDateTime(); gs.info(gdt.getMonthLocalTime());
Please let me know what am I doing wrong
Thanks,
Ming.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2019 09:03 AM
javascript:new GlideDateTime().getMonth()
Try putting the following in the default value field.
If this resolved your issue, please mark this as helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2019 09:02 AM
Check this
getMonth() is what you are looing for
https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_GDT-getMonth
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2019 09:03 AM
javascript:new GlideDateTime().getMonth()
Try putting the following in the default value field.
If this resolved your issue, please mark this as helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2020 08:05 AM
Hi Elijah,
how can we fetch "month" for a custom date field on value change? (10-12-2020) format.
This is client side
Regards
Priya