Validate current date with captured text

This is the date format of file modified that will be captured from application: Jun 30 09:11 ( without Year)

We need to validate this captured text with current date and If, file modified date is greater or equal to 90 days from current date then give output as YES else NO

Hi @Sathish_Kumar_S ,

  1. Use an “Assign” activity to capture the current date using the following expression:
DateTime.Now.ToString("MMM dd HH:mm")
  1. Use a “If” activity to compare the captured file modified date with the current date. The expression would look something like this:
FileModifiedDate >= DateTime.Now.AddDays(-90)

  1. Inside the “If” activity, use a “Assign” activity to assign the value “YES” to a variable if the condition is true.
  2. Use an “Else” activity to assign the value “NO” to the same variable if the condition is false.
  3. You can use a “Message Box” activity to display the result of the comparison.

Thank you… Since there is no year in the captured text… the captured month and date will be from last year or current year?

Hi @Sathish_Kumar_S ,
Unfortunately, it’s not possible to determine the year from the date format “Jun 30 09:11” as it is ambiguous. To validate the date, you’ll need to either:

  1. Store the current year in a variable and append it to the captured date before performing the comparison.
  2. Make an assumption about the year (for example, always assume the current year) and perform the comparison based on that assumption.

@Sathish_Kumar_S

it is not possible to compare the dates without having year in the extracted text, as the robot can not confirm the input year.

Can you try fetching the complete date from the underlying attributes of the text in the web page?

Cheers

There is no way to get the year…

is it possible to add last year if the month in the file info is behind current month else add current year and validate?

we can do it. But, what if in the scenario of fetched month is Dec. since we are in Feb 7th 2023, 90 days backward is Nov 7th 2023.

As per your logic, the fetched date will be in Dec 2023 which will not work.

so, it is recommended to have fetched the year from any of the attribute from the input.

Cheers

It is not web page… We are extracting it from Putty application