How to know the exact day of the week from a Date/Time field

Alon Grod
Tera Expert

Hi,

Is there any way to know the exact day of the week from Date/Time and the exact time that was chosen

4 REPLIES 4

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Alon Grod ,

 

There is a function which can let you know that , refer the below script.

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

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

@Sohail Khilji and how can I get the exact time from the date?

the date and time field consist of 2 components once is date and another is time , you can refer the 2nd segment to get the time.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Community Alums
Not applicable

Hi @Alon Grod ,

Please try below code may be this will work you 

var gdt1 = new GlideDateTime();
gs.print(gdt1.getTime().getDisplayValue());
 
Please mark my answer correct and helpful if this works for you
Thanks and Regards 
Sarthak