Details
The following KB details how users/admins should be using the getDayOfWeekLocalTime() method in business logic. This method will return a numerical value between 1-7 as it corresponds to the number of days in a week. The breakdown is as follows:
1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday
7 - Sunday
This method should only used against date/time objects in business logic. Using the method for a date object will result in unexpected results as the method is specifically for date/time objects.
Ex:Improper use
var startDateTime = new GlideDateTime("2019-08-22 12:00:00");
var startDate = startDateTime.getDate();
gs.print("@@@ TEST DATE START " + startDate);
gs.print("@@@ TEST DAY OF WEEK IS " + startDate.getDayOfWeekLocalTime());
This will return a value of 3 instead of 4 when we pass in 2019-08-22 12:00:00 which is Thursday
Proper Use:
var gdt = new GlideDateTime("2019-08-20 12:00:00");
gs.print(gdt.getDayOfWeekLocalTime());
This will return a value of 2 as the 20th corresponds to a Tuesday and we have passed the method in using a date/time object