Page 1 of 1

Generate Random Date

Posted: Wed May 10, 2017 12:49 pm
by criptich
I have this


SET !VAR1 EVAL("var d=new Date();d.setDate(d.getDate()-1);var year=d.getFullYear();var month=d.getMonth()+1;var day=d.getDate();year+'-'+month+'-'+day;")
'SET !VAR2 EVAL("var d=new Date();d.setDate(d.getDate()-180);var year=d.getFullYear();var month=d.getMonth()+1;var day=d.getDate();year+'-'+month+'-'+day;")
'SET !VAR3 EVAL("var randomNumber=Math.floor(Math.random()* {{!VAR2}} + {{!VAR1}}); randomDate;")
'SET !VAR3 EVAL("int days = Days.daysBetween(d1, d2).toDays(); LocalDate randomDate = d1.addDays(ThreadLocalRandom.nextInt(days+1));")
'ADD !EXTRACT {{!VAR1}}



SET !VAR2 EVAL("var randomNumber=Math.floor(Math.random()*"{{!NOW:yyyy/mm/dd_hhnn}}" + "{{!VAR1}}"); randomNumber;")
TAG POS=1 TYPE=INPUT:SEARCH FORM=ID:searchform ATTR=ID:searchInput CONTENT={{!VAR2}}

I just want the content of CONTENT={{!VAR2}} to be a random date between NOW and 6 or 9 or 12 or however many months before now. I want a random date in the given year month day format to be entered into the text spot that I have with the given input command above. so basically i want !VAR2 to be a completely random date OR even a fixed date from NOW to x days/x months ago such as a result of.
my purpose behind this is to just have a random date between to be entered into the given field each execution. i've found randomDate and i've been trying to figure out how to use it within imacros as well.