How to "type into" variable date

Hello,

I am looking to pull a date from excel (MM/dd/yyyy format in excel) and type the row of dates into a website for each row of the excel. I will then need to type another date into the website that is 30 days after the first date that was typed into the website.
I can type the first date in perfectly fine by passing the date as a string, however the second needs to be DateTime formatted to handle the addition of the 30 days the bot will be adding.
I am having issues with the “String was not recognized as a valid DateTime” error at the moment.

Legend: = Activity input area

Read Range - ExcelData (Variable datatable output)
For Each Row - ForEach [row] in [ExcelData]

Assign -
[InputDate] = [DateTime.ParseExact(row(“DOS”).ToString, “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture)]

Type into - [InputDate]

Type into - [InputDate.AddDays(30).ToString(“MM/dd/yyyy”)]

Variables: - Excel Data = DataTable (Variable type)
InputDate = DateTime (Variable type)

1 Like

@Steven_Weatherhead,

Add the days and assign the new value to a variable of type string and then try to write it . It will work

1 Like

Hi
We are good at everything along the process here but I think the format is the issue
So when we extract from excel we will be getting in the format of
MM/dd/yyyy hh:mm:ss
So we need to have as

InputDate = DateTime.ParseExact(row(“DOS”).ToString.Substring(0,10), “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture)

That would work for sure or if still the issue persists
The kindly check with the value of the date extracted from the excel with the help of a writeline activity before to the assign activity
Like this row(“DOS”).ToString
And check what is the value and what is the format of the date so based on that we can mention in the datetime parsing

Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @Steven_Weatherhead

1 Like

Thank you @Palaniyappan and @HareeshMR for the fast correct responses. I appreciate it a ton!!

1 Like

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