Hi Team,
I have a datatable with the column name as “time”.
Where time is 12 hours format and AM/PM is mentioned in the excel file.
For e.g. 2:45 PM, 11 AM like this.
So here I want to do comparison using filter data table activity. However can’t filter it out, as it has AM and PM mentioned in the column name.
How to solve this issue? Let’s us consider, current time is 3PM and I was latest messages which are within 30 mins scope.
So if “time” column has value 2:45 PM, that it should be kept in the datatable. Any insight would be appreciated.
I using following condition in filter data table :
“time” < System.DateTime.Now.ToString("hh:mm”)
We could use the Linq Method to Filter out the rows based on Date Values.
However if the format of the Time appears in the quoted format above, we might need to perform a String Substitution/Replace on . before proceeding with Parsing of the String.
The Expression to Filter out the rows using a Linq would be like below :
Hi supermanPunch, Thanks for the reply. I’m sorry for the typo:
Time is in the format of 2:45 PM, there is “:”
Also, I have another question. If time column from the datable is not in date time format, than how would this expression work?
We, first might need to convert into date time format(It’s in General Format in excel) and need then need to compare right?
And, I trying to solve this using “filter data table activity”. As I have lots of other condition for other columns as well.
@Shantanu_More1 , This is the approach we do normally for these kind of situations.
The Filter Datatable Activity might not be able to perform the comparison in the right way.
You Could try First Converting the Value in Time Column to a TimeSpan format by adding Another Column of TimeSpan Type to the Datatable.
Then you would need to update the New Column by Converting the Value in Time Column to Timespan and assigning it to the new Column.
Now, Most probably after the Updation of the new Column, we should be able to perform a Comparison between TimeSpan Column created and Now.TimeOfDay using a Filter Datatable Activity.
Since, these are all Extra Steps required for Filter Datatable Comparison, we go with the Linq Approach.