Random Date in a Computer Vision input

HI i couldnt find any similiar issue when searching for it.
Im running a research project where Ui path fills in specific fields in the browser with computer vision.
One of these fields is a Date input that needs to be randomizied between two specific age categories. For example the Typed in date should be randomizied between the 01.01.1970 and the 31.12.1980
I found how i create randomized dates but couldnt figure out what i need to put in the “Type This” field to get the randomizied date typed in:
grafik

Hi @inno

Welcome to Community!!

Can you try below to get random date from 2 different dates

RandomDate=New DateTime(1970, 1, 1).AddDays((New Random()).Next(CType((New DateTime(1980, 12, 31) - New DateTime(1970, 1, 1)).TotalDays, Integer))).ToString("dd.MM.yyyy")

Regards,

1 Like

Hi @inno

Try the below syntax:

RandomDate= DateTime.ParseExact((New DateTime(1970, 1, 1)).AddDays((New Random()).Next(0, (New DateTime(1980, 12, 31) - New DateTime(1970, 1, 1)).Days + 1)).ToString("dd.MM.yyyy"), "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd.MM.yyyy")

Regards

@inno

New DateTime(1970, 1, 1).AddDays(New Random().Next(0, CInt((New DateTime(1980, 12, 31) - New DateTime(1970, 1, 1)).TotalDays))).ToString("dd.MM.yyyy")
1 Like

Thanks vrdabberu @rlgandu @lrtetala it worked now it puts in the random Birth year in the field with computer vision!

2 Likes

Hi @inno

Perfect. Since your query has been resolved, please mark my post as solution to close the loop or if you have any queries, I’m happy to help.

Happy Automation!!

Why are you using Computer Vision to type into a browser window? CV is for things like Citrix and RDP where you can’t get normal selectors. From a browser window you can get normal selectors and should just use the regular Type Into.

Also, you should be working in modern and using the latest version of your dependencies, which will have CV built into the regular activities (instead of using the CV-specific activities).

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.