Datatable select rows with date of specific month.

Hi, I have a datatable with a column called “Initial Generation Date” which contains dates in text format (MM/dd/yyyy HH:mm:ss)
I would like to select and count rows where the column is from the same month.

Hey,

You can use the datatable.select to select the rows that interest you

Here is the syntax :

Assign
my_datarow_array= my_datatable.Select(“convert([Initial Generation Date], ‘System.String’) Like ‘%/01/%’”)

This will return you a array of all the datarows that contain “/01/” which translates to January as the variable my_datarow_array

If you want to do this for all the months all you need to do is create an array that contains all the possible months.

my_arrayMonth={"/01/","/02/","/03/","/04/"…etc…"/12/"}

Then use a For each item/month in my_arrayMonth in order to loop through all the months in your Excel.

Please feel free to notify me if you think this was clear or if you have any additional questions :slight_smile:

2 Likes

thank you so much!!!