@manjesh_kumar
Before forcing of doing with LINQ lets divide and conquer on the different building blocks.
Part: Week Info recognition
Week portion is not part of the date format patterns, so we have to handle different. also we do have different cases to approach: week, week range, date.
For recognizing it we can make use of Regex and Group names:
we do init a regex object with the pattern
we do iterate and execute the regex.match
in a switch we do calculate which of the group was firing and will use the group name for the fork
Other Steps
within the cases we can do the additional parsing, date calculation and target datatable population.
Getting date from WeekNo, have a look here for a similar sample as starter help:
For the part from above find starter help here: manjesh_kumar.xaml (9.6 KB)
I think you can never get this 100% solid, if the sourcefields are human free-text input, since it’ll leave too many combinations to validate, especially if one value can be interpreted multiple ways.
if I gave this field 1-3-20 do I mean the week of March 1st 2020, January 3rd? Week 1, 3 and 20, week 1 through 3 in 2020?
You should expect a margin of error trying to decypher this. It depends of course on your process if this is acceptable or maybe even business critical.
A better solution would be to apply input validation on your entry forms. If that is excel it is certainly doable, or otherwise the input form in your front end, which usuually requires a few less accesible changes to the form. Even a proper workinstruction towards the people who provide the data might help.
In short; make it strict, dummy proof or robot friendly, anyway you want to call it But please don’t make the robot guess a format. Structured data is a prime requirement of RPA. (At least untill AI matures a lot more)
I understand the last paragraph isn’t always within your direct influence as an RPA developer, but I’d put on my ‘business analyst’ hat and provide that feedback towards your requesters, to either change the input, or expect and accept a lot of process exceptions.