Hi,
I have a Data Table with date column. I need to find the oldest date from this column and filter and remove rows with oldest date from the data table. What is the best way of doing this?
Many Thanks,
have you tried the following methods?
Hi @robot123 ,
Max Date
DateTime maxDate = Convert.ToDateTime( ((from DataRow dr in dt.Rows orderby Convert.ToDateTime(dr["DateColumn"]) descending select dr).FirstOrDefault()["DateColumn"] ) )
Min Date
DateTime minDate = Convert.ToDateTime( ((from DataRow dr in dt.Rows orderby Convert.ToDateTime(dr["DateColu…
Hi All
I need to find the maximum and minimum dates in a datatable. Can anyone please help me in this
@aksh1yadav , @vvaidya
Hi there @Alexey ,
You can use the following expression:
[YourDTVariable].AsEnumerable().Max(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString
This will return a String value.
On a side note, you will receive an error in the event any of these values cannot be parsed as a DateTime.
Thanks,
Josh
system
(system)
Closed
October 7, 2022, 1:16pm
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.