Find the maximum and minimum dates in a datatable


#1

Hi All

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


#2

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


#3

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


#4

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


#5

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


#6

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


#7

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

Regards
Balamurugan.S


#8

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


#9

Hi @Divyashreem

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

Thank you


#10

Hi @divyaag,

Here I have attached the installation guide.

After finished the Installation restart the studio.

グループ集計

Regards
Balamurugan


#11

Thanks @balupad14


#12

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”
}


#13

Hi @divyaag,

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

Regards,
Arivu


#14

Hi @arivu96

[test.xaml (12.2 KB)

Please find that file and kindly help me here


#15

@ arivu96

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

Thank you