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))

Or
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

Regards,
Arivu

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.

MaxMin.zip (2.6 KB)

Note :

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

Regards
Balamurugan.S

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

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

Regards
Balamurugan.S

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.

グループ集計 - #6 by balupad14

Regards
Balamurugan

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”,
“robotName”: “SALINDIA\LOTUSINFOTECHVINOTHK”
}

Hi @divyaag,

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

Regards,
Arivu

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

Hi All,
I get the same error as @divyaag.

Assign: Syntax error in aggregate argument: Expecting a single column argument with possible ‘Child’ qualifier.

Can anyone provide a solution for this pls?

Hi… The below solution from @arivu96 from another similar post solved my issue

Convert.ToDateTime(dt.AsEnumerable().Max(Function(row) row(“ColumnName”)))

Thank you

dataTable.AsEnumerable().Max(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString - Worked for me, thanks