- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2022 09:45 PM
Hi All,
I know how to add months in scoped applications(I hope below code works for it), but need some more info...
There is a "Date" field on the table... when I run the code, then it needs to update the date as "Next month first date"
Ex: Suppose if date is 18-04-2022(It will be dynamic), after the code runs it needs to update as 01-01-2022
var datee = new GlideDate();
datee.addMonthsUTC(1);
gs.info(datee);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2022 10:14 PM
Hi,
check this link
How to find the first day of Month
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
‎04-17-2022 10:03 PM
Hi,
addMonthsUTC is on GlideDateTime and not GlideDate
var datee = new GlideDateTime();
datee.addMonthsUTC(1);
gs.info(datee);
Regars
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
‎04-17-2022 10:05 PM
Hi,
if date is 18-04-2022 then next month's first date is 1st May 2022
You can add 1 month to your date; then determine the first day of that month; anyhow it would be 1st
So once you know the current month i.e. April; you can get 1st May
Regars
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
‎04-17-2022 10:11 PM
I tried the below code
var datee = new GlideDateTime();
datee.addMonthsUTC(1);
var date = datee.beginningOfThisMonth(datee);
gs.info(date);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2022 10:14 PM
Hi,
check this link
How to find the first day of Month
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
