Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 06:03 AM
Hi.
Please help me populate the month and week fields based on the date I select for the day field.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 06:31 AM
Please use the following code snippet and make necessary changes-
var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var prefixes = ['First', 'Second', 'Third', 'Fourth', 'Fifth'];
var gdt = new GlideDateTime();
var month = monthNames[gdt.getMonthLocalTime()] + ' ' + gdt.getYear();
var weekNumber = Math.floor((gdt.getDayOfMonthLocalTime() - 1) / 7);
var weekPrefix = weekNumber < prefixes.length ? prefixes[weekNumber] : '';
gs.log('This is ' + weekPrefix + ' Week of Month ' + month);
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 06:07 AM
Hi @darianistor
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 06:31 AM
Please use the following code snippet and make necessary changes-
var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var prefixes = ['First', 'Second', 'Third', 'Fourth', 'Fifth'];
var gdt = new GlideDateTime();
var month = monthNames[gdt.getMonthLocalTime()] + ' ' + gdt.getYear();
var weekNumber = Math.floor((gdt.getDayOfMonthLocalTime() - 1) / 7);
var weekPrefix = weekNumber < prefixes.length ? prefixes[weekNumber] : '';
gs.log('This is ' + weekPrefix + ' Week of Month ' + month);