Get Specific Day of the Week

Sabrina10
Kilo Guru

I have table with a date field.     Sometimes that date could fall on a Tuesday, Wednesday, Thursday, Friday, etc.

I want to find the Monday of the week that date falls in.     Is there a specfic function to find a specific day of a certain week? I know I can find out what week it is using getWeekofYearUTC(), but is there a way find the Monday of Week 24?

or is my best option to write something like this:

var gdt = new GlideDateTime('2017-10-17 12:00:00');

var dy = gdt.getDayOfWeek();

if (dy == 2) {

gdt.addDays(-1)

}

if (dy == 3) {

gdt.addDays(-2)

}

...

gs.print(gdt);

1 REPLY 1

Harish KM
Kilo Patron
Kilo Patron