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.

Moderators: Community Moderators, iMacros Moderators

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.

Generate Random Date

by criptich on Wed May 10, 2017 12: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.
criptich
 
Posts: 1
Joined: Wed May 10, 2017 12:17 pm

Return to General Support & Discussions

Who is online

Users browsing this forum: Google [Bot] and 4 guests

-->