How to take Item from List of String and change it to DataTime?

Hi everyone.

I try to convert items from a List of Strings(listDelivery) to a DateTime variable to compare each of them with the actual date and return just future dates, also this date should have the right format (“”).
But when I try to convert by using ForEach and write in Assign:


Compiler write something like that
“Option Strict On” does not allow implicit conversions from “string” to “integer”

Do you have ideas on how to solve this problem?

p.s. List of Strings I make from excel table which has other values and if date haven’t the right format, the row which containing this bad date should be deleted

Are you sure that item is the index and not the current string from the list?

Item is the current string from the list.
When I tried to use an index, compiler wrote Assign: String was not recognized as a valid DateTime. So I thought what it’s not the right way.

If item is the current string then you shouldn’t be using it like listDelivery(item) but as simply item.
The error " Assign: String was not recognized as a valid DateTime" means that you’re using the wrong format. Could you post how an item would look like?

Hmm, when I change to just item, compiler show the same error

Could you post a sample string?

Sorry, I understand you not correctly.
Here is how strings look like
2020-07-22 (1)_cr

find a demo XAML handling defensive the date parsing and also supporting multiple formats if required:
StringList_DefensiveParsing.xaml (9.2 KB)


Wow, it looks like a solution!
How to climb to that high of knowledge? : sweat_smile:: open_mouth:
Ahead of me is still a long road to gain knowledge.
A lot of thanks!

Hello again
Your solution worked, but after I filter DataTable for removing random nums, it begins to show that it works in Output panel, but not really work in Debag Locals panel and doesn’t want to write changed data to excel-file, for some reason…

2020-07-22 (6)_cr
Could you help, please?..

maybe you can share some more details on your flow.
in your screenshot the top item “item” is matching the output log. Are you refering to something different?

“item” is an item from List of String with dates in the format “MM/dd/yyyy HH:mm:ss” which takes from my DataTable. I try to change it to “dd.MM.yyyy” by using your sequence:

but for some reason dates change just in Log Message.
After this operation, it writes to excel-file with other associated files

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