Calender Date Selection

Hello my friends, I need help with my Automation. Im trying to select a date automatically. Type into activity is not possible. The robot has to click forward until he is on the Calender site with the correct Month and year. The selectors work fine but the robot does not stop when DateToday=OldDate.
Does anyone have an Idea what the problem or a different solution?

Hello Shakib! It sounds like you’re trying to automate the process of selecting a date from a calendar, where the robot should stop once it reaches the correct date.

To address this, here’s a potential solution using UiPath:

1. Identify Current Date

First, you need to get the current date using Assign activity. This will help in determining when to stop.

DateTime.Now.ToString("dd/MM/yyyy")

2. Check Date on Calendar

When the robot clicks to open the calendar, you can use the Get Text activity to capture the date displayed on the calendar and compare it with the current date (DateToday).

For example:

  • Use Get Text to capture the current date visible in the calendar.
  • Compare this captured date with OldDate (which could be the date you’re looking for).

3. Clicking through Calendar

You can use a loop to simulate the clicking process:

  • Get the Text (Month/Year) using Get Text activity.
  • Compare the month and year with the target one.
  • If the month or year is not correct, use Click to move forward or backward to the next month.
  • After finding the correct month and year, use Click to select the correct day if it matches DateToday.

Example Flow:

  1. Start: Use Click to open the calendar.
  2. Get Text: Use Get Text to capture the current month and year on the calendar.
  3. If Condition: Compare if the displayed date matches OldDate.
  4. Loop: If not, use Click to go forward or backward through the calendar and repeat the Get Text and comparison steps until the correct date is found.
  5. Stop when correct date is found.

Common Pitfalls:

  • Ensure that the Get Text selector accurately targets the correct part of the calendar.
  • Ensure that there’s enough time for the calendar to load before checking for the correct date.

Let me know if you need help with specific details!

Hi,

For now, can you check content of both variable : DateToday and OldDate in Locals panel using break point etc?
Also it may help to use Trim method to remove extra white space.

DateToday.Trim=OldDate.Trim

Regards,

Hi Yoichi thank you,
I added the .Trim and the locals pennel tells me the correct dates but the robot still does not stop.

Hi,

For now, can you try to output the following expression and check if there is difference b/w them? (ans/or share them?)

String.Join(",",oldDate.Select(Function(c) AscW(c)))

String.Join(",",DateToday.Select(Function(c) AscW(c)))

Regards,

Hi,

Do you mean like this in a log message?
Screenshot 2024-12-11 094022

Hi,

Thank you for sharing

The former is Oktober 2022
The latter is Dezembeer 2024
However, the former contains non break space (U+00A0 = 160)

So can you try as the following?

formerString.Trim.Replace(ChrW(160)," ") = latterString.Trim

Regards,

1 Like

Thank you Yoichi,
You are a very smart man !

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