DesTo
March 14, 2020, 1:48am
1
Hello,
I have 2 questions :
1/ I would like to define a variable as the date -4 days, so I know I have to use executeScript and the following command, but how to define the date - 4 days ?
executeScript | var d=new Date(); return d.getDate()+‘/’+((d.getMonth()+1))+‘/’+d.getFullYear();
2/ Then I would like to use this variable inside the folowing url where I have to replace the 3 sample with the same variable “date” and then open this url :
https://sellercentral.amazon.fr/gp/site-metrics/report.html#&cols=/c0/c1/c2/c3/c4/c5/c6/c7/c8/c9/c10/c11/c12/c13/c14/c15&sortColumn=16&filterFromDate=11/03/2020&filterToDate=**11/03/2020**&fromDate=**11/03/2020**&toDate=**11/03/2020**&reportID=102:DetailSalesTrafficByChildItem&sortIsAscending=0¤tPage=0&dateUnit=1&viewDateUnits=ALL&runDate=
Thanks for your help !
This will get you the date -4 days in the format mm/dd/yyyy:
executeScript_Sandbox | var d= new Date(new Date().getTime() + 24 * 60 * 60 * 1000 * -4); var m=((d.getMonth()+1)<10)?'0'+(d.getMonth()+1):(d.getMonth()+1); m=m+"/"+d.getDate().toString().padStart(2, "0")+"/"+d.getFullYear(); return m | myvariable
You can now put that date wherever you would need it:
mywebsite.com/fromdate${myvariable}/test
1 Like
DesTo
March 15, 2020, 10:59am
3
Ok, thanks for your help !
DesTo
March 15, 2020, 11:51am
4
Hello,
Just one last question, if I need the date -4 days in the format dd/mm/yyyy ?
Thanks
Just reverse the month and day:
executeScript_Sandbox | var d= new Date(new Date().getTime() + 24 * 60 * 60 * 1000 * -4); var m=((d.getMonth()+1)<10)?'0'+(d.getMonth()+1):(d.getMonth()+1); m=d.getDate().toString().padStart(2, "0")+"/"m+"/"+d.getFullYear(); return m | myvariable
3 Likes