About the FAQ category

Find answers to some of the most common questions about Robusta RPA products and community initiatives here.

Returns the date of the first day of the week in which the operation was performed.

:arrow_down:

var dt = new Date(); 
var month = [1,2,3,4,5,6,7,8,9,10,11,12];
var currentWeekDay = dt.getDay();
var toDay = dt.getDate();

 

var lessDays = currentWeekDay == 0 ? 6 : currentWeekDay - 1;

var wkStart = new Date(new Date(dt).setDate(dt.getDate() - lessDays));
var wkEnd = new Date(new Date(wkStart).setDate(wkStart.getDate() + 6));

 

var fday = wkStart.getDate();
var fmonth = month[wkStart.getMonth()];
var fyear = wkStart.getFullYear();

if(fmonth<10){
fmonth="0"+fmonth.toString();
if(toDay==1){
fday = "01";
}
}
else{
fmonth =fmonth;
}
var firstDate = fday.toString()+fmonth.toString()+fyear.toString(); 


execution.setVariable("firstDate",firstDate);

 
Output:  

 "firstDate : 4042022"