How to get first day of the specific month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2022 10:48 PM
Hello All,
I am trying to get the first day of the specific month.
ex: someone passes (-2 from the current month), so end date should be 2021-11-31 and start date should be 2021-11-01.
Please let me know how I can get it.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2022 10:56 PM
Hello
Please try below script
var gdt = new GlideDateTime(date);
var dt= gs.beginningOfThisMonth(gdt);
gs.print(dt);
gs.print(gdt.getDayOfWeek());
Also check this community link for more info https://community.servicenow.com/community?id=community_question&sys_id=69c1df6ddbdcdbc01dcaf3231f96...
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2022 11:02 PM
Hello Sulabh,
I already tried this code but it is giving me 01-01-2022.
and I want 01-11-2021.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2022 11:03 PM
Hi,
what will be the user input?
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
01-23-2022 11:04 PM
Hello Ankur,
var contract_date = new GlideDateTime("2021-11-20 12:00:00");
thanks