The CreatorCon Call for Content is officially open! Get started here.

Get day of the week from date field

JJG
Kilo Guru

I have a date field on a record, I would like to pull the date and get the day of the week from it. Heres what I have so far:

var grDay= new GlideRecord('x_utsll_time_manag_hour_tracker');
grDay.query();
while (grDay.next()) {
     var testdate = grDay.date;
     var dy = testdate.getDayofWeekLocalTime();
     gs.info('Day:'+dy);
     }

Doesn't seem to work, getting an error in the log

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

try

var grDay= new GlideRecord('x_utsll_time_manag_hour_tracker');
grDay.query();
while (grDay.next()) {
	var gdt = new GlideDateTime(grDay.date + ' 12:00:00');
	var dy = gdt.getDayofWeekLocalTime();
	gs.info('Day:'+dy);
}

View solution in original post

6 REPLIES 6

rajneeshbaranwa
Giga Guru

Try using below:

 

Please note there is capital O in getDayOFWeekLocalTime() 

Please mark my answer correct/helpful , If it helped you.

var grDay= new GlideRecord('x_utsll_time_manag_hour_tracker');
grDay.query();
while (grDay.next()) {
     var testdate = new GlideDateTime(grDay.date);
     var dy = testdate.getDayOfWeekLocalTime();
     gs.info('Day:'+dy);
     }

 

Made that change and still got an error:

 

org.mozilla.javascript.EcmaError: Cannot find function getDayOfWeekLocalTime