Hi everyone,
I need your help. I want to write a sentence in a new file. The contents of which are “first data” where the final sentence comes out when the robot walks between 08:00-09:59, “second data” where the sentence comes out when the robot walks between 10:00-11:59, and "third data ” where the sentence comes out when the robot is running between 12:00-13:59. How can I produce the desired output according to the time of playing the UiPath robot
Use if condition to check if the current time is between the required time
Eg: for 8 to 190 use Now.Hours>=8 and Now.Hours<10
Use the above statement in if and on then sude use first sentence…on else side use one more if with 10 to 12 and on then side use second statement…similr for 12 to 2
Hope this helps
Cheers
Hi @wsinten ,
You need create two variable
startTime - TimeSpan type variable
endTime - TimeSpan type variable
Then get start time while starting the workflow System.DateTime.Now.TimeOfDay into the startTime variable using Assign activity
At end of the workflow get endTime using assign activity like this System.DateTime.Now.TimeOfDay.Subtract(startTime)
Use write range or write cell activity t write data to excel
regards,
Hi @wsinten
-
Drag and drop an “Assign” activity onto your workflow.
-
In the “To” field, create a variable to store the sentence based on the time. Let’s call it
outputSentence
of type String. -
Use the following VB.NET code in the “Value” field to set the
outputSentence
variable based on the current time:
DateTime currentTime = DateTime.Now;
if (currentTime.Hour >= 8 && currentTime.Hour < 10)
{
outputSentence = "first data";
}
else if (currentTime.Hour >= 10 && currentTime.Hour < 12)
{
outputSentence = "second data";
}
else if (currentTime.Hour >= 12 && currentTime.Hour < 14)
{
outputSentence = "third data";
}
else
{
outputSentence = "No data available at this time.";
}
-
Next, you can use a “Write Text File” activity to create a new file and write the content of the
outputSentence
variable to it. -
Customize the file path, name, and any additional settings in the “Write Text File” activity based on your preferences.
This workflow will set the outputSentence
variable based on the current time and then write the corresponding sentence to a new file.
Hope it helps!!
hi @Nguyen_Van_Luong1 @Parvathy @Anil_G ,
thank you for helping. the above problem has been solved. Thank You
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.