Generate Random Date

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information:CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
criptich
Posts: 1
Joined: Wed May 10, 2017 7:17 pm

Generate Random Date

Post by criptich » Wed May 10, 2017 7:49 pm

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.
Post Reply