I have a Datatable extracted using a query from a database with the following columns: Name, PassportNumber, ExpirationDate, Citizenship, PassportCountry
Now my duty is to check:
Missing Expiry Date
Expired ID/Passport
Mismatch of Citizenship and PassportCountry
Missing Citizenship
Whats the fastest way to do these comparisons and to have a new datatable with added columns:
Missing/Expired Date
Stores False/True values if the passport is expired of expiration date is missing.
Missing/Mismatch Citizenship
Stores False/True values if the Citizenship is missing or it does not match with
PassportCountry.
Should I go with add column activitiy and then for each loop checking each value or is there a faster way, if yes whats the conditions.
Do Check the Below for more methods on Updating Datatable Columns :
Do Check first if the Data Column Expression Approach can be used in your Scenario. It does seem that you need True/False as Output Column Values, which might be easier to use with this method.
If this Method doesn’t provide the required result, let us know we could maybe provide a Linq Query which would be an alternate method.
Thank you @supermanPunch
What would be the expression in this scenario, [ExpirationDate] to check if its null or empty ?
Otherwise will go for the long way for each method.
If the above doesn’t work, we would need to know the format of the date value Either using Debug or Write Line Activity by Specifying CurrentRow.Item("ExpirationDate").ToString as the Value.
Since this is used in a For Each Row Loop, there is a Possibility that the Date Column value can be empty as well. Use an If Activity to Check the Condition is true like below :
@hurmet.noka , If you do further Analysis, we could find that the CurrentRow("ExpirationDate") or CurrentRow.Item("ExpirationDate") outputs a Object Type and not it’s DataColumn type.
Hence, We would require to Explicitly Convert the Value to It’s Required Type, For Date values, we use DateTime.ParseExact(), CDate(), DateTime.Parse() as applicable for the values.