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 Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.
Post Reply
ghostpom12
Posts: 1
Joined: Wed Jul 04, 2018 2:50 am

Generate Random Date

Post by ghostpom12 » Wed Jul 04, 2018 2:57 am

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