Find the maximum and minimum dates in a datatable


Hi All

I need to find the maximum and minimum dates in a datatable. Can anyone please help me in this
@aksh1yadav , @vvaidya


Hi @divyaag,

maxDate = Convert.ToDateTime(dataTable.Compute("MAX(TheDateColumnName)", null))
minDate = Convert.ToDateTime(dataTable.Compute("MIN(TheDateColumnName)", null))

dataTable.AsEnumerable().Max(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString

dataTable.AsEnumerable().Min(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString



Hi @arivu96

Thanks for helping me out …
I have tried Convert.ToDateTime(dataTable.Compute(“MAX(TheDateColumnName)”, null)) to assign one datetime variable. but am getting the below error

. Kindly help me


Try - System.DBNull.Value.ToString instead of null


Hi @divyaag,

Here I have sample to get the Max and Min date from datatable Using the BalaReva.Datatable.Activities. (2.6 KB)

Note :

After opened the Project please install the below package and save it. Reopen the project.



As error clearly Saying the issue replace null with System.DBNull.


have you tried with my sample. or attached your xaml. I will check …



Hi @balupad14

I have tried to execute the code but am getting the below package error… I have installed all the packages but not sure why am getting this. can you please help


Hi @Divyashreem

I have tried with that but still I was getting the error. So, I provided " " then it got resolved.

Thank you


Hi @divyaag,

Here I have attached the installation guide.

After finished the Installation restart the studio.




Thanks @balupad14


Hi @arivu96,

am getting the below error, can you please help .

“message”: “Assign : Syntax error in aggregate argument: Expecting a single column argument with possible ‘Child’ qualifier.”,
“level”: “Error”,
“logType”: “Default”,
“timeStamp”: “16:59:31”,
“processVersion”: “1.0.6850.25695”,
“fileName”: “test”,
“jobId”: “db0f027e-32b3-44c9-8667-fc0bdd58e1f0”,


Hi @divyaag,

can you share your xaml file and input so i can give the correct solution.



Hi @arivu96

[test.xaml (12.2 KB)

Please find that file and kindly help me here


@ arivu96

actually am scrapping the datevalue from datatable and trying to find the highest value out of it.

Thank you