Get the date , month , Year from get text in different format


Need help to find the date month and year to compare with different format date.
Getting this from Get Text : Oct 29, 2022
This is my last report date , there is no reports available for 30,31…
So, Every day my bot is downloading 3 days reports and update on database that it downloaded report for this date as “Completed”.
Let’s say Today is 31 date and I have to check reports for 31,30,29 dates - database said all 3 reports need to download.
How can i identify the get text date and find accordingly.

Let me know if need more details.

Thank You


To convert text with format ‘Oct 29, 2022’ try to use this:

DateTime.ParseExact("Oct 31, 2022","MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture)

Extracting month:

DateTime.ParseExact("Oct 31, 2022","MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture).Month

Extracting year:

DateTime.ParseExact("Oct 31, 2022","MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture).Year


1 Like

Hi @Konrad_Mierzwa How should I put the variable of get text inside this formula you provided ? Or how should I put a text “Oct 31, 2022” inside this formula ?

Every time date should be different.

When I add the get text variable instead of Date string It is giving below error.
Log Message: String was not recognized as a valid DateTime.

Using variable:

DateTime.ParseExact(yourStringVariable,"MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture)

Your get text variable have exactly the same format? Can you share it? Maybe there is some additional space or something

See below screenshot from Logs. I think yes there is space.

Log Detail : image

Ok, try with Trim:

DateTime.ParseExact(yourStringVariable.Trim,"MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture)

Still same error. Log Message: String was not recognized as a valid DateTime.


Could you maybe perform a Debug and Check the value of the Get Text Activity’s output variable in the Immediate Panel. Also try using Write Line Activity and use only the output variable as the value. After the Execution, Double click on the value in the Output Panel, we should be able to see if there any extra characters/spaces. We should then be able to take the necessary actions.

1 Like

this is immediate panel output :

Then I am using below formula to get the date.


Could you change the Expression to the below and Check :


Not so sure if the index returned by Variable.Split(“:”.ToCharArray).Length-1 was the correct one.

Let us know if the modified expression above also received the error.

1 Like

If @PALKUMARI_PATEL solution still does not work please copy and paste here text of your variable. Maybe there are some unvisible special characters.

Still same error.

See log copied from get text variable .
Report Updated: Oct 29, 2022

From Ui Explorer :aaname=‘Report Updated: Oct 29, 2022’


Was this Checked ?

This expression works for you with hardcoded date ‘Oct 31, 2022’?

DateTime.ParseExact("Oct 31, 2022","MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture)

Is this value


different than “Oct 31, 2022”?

This is from Write line : “message”: “Report Updated: Oct 29, 2022”,

yes, that expression works for hardcoded value.

No, that date is same format. See “message”: “Last Updated Report Date : Oct 29, 2022”,

Ok writeline this code and we will see:

(Variable.Split(":".ToCharArray)(1).ToString.Trim="Oct 31, 2022").ToString

Yoy got true or false? :slight_smile:

got true .

This expression works for hardcoded “Oct 31, 2022”

DateTime.ParseExact("Oct 31, 2022","MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture)

And we are 100% sure that this expression has the same value as “Oct 31, 2022” (you got true)


So this expression also must work in the same place:

DateTime.ParseExact(Variable.Split(":".ToCharArray)(1).ToString.Trim,"MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture)