How to filter datatable from Jan to Nov (current month)

Hi ,

I need to filter / select from datatable from Jan to current month i.e Nov ( for now).
@ClaytonM

This is how input looks

Ahtesham

Hi @md.ahtesham,

1.Is the months are in the string format like “Jan”?
2.If the months are in the number format like 1 ,then you can filter it using the filter data table activity.
3. Condition like ColumName<12.

Cheers.
Vashisht.

Hi.

It’s best to filter using the values as DateTimes rather than extracting the month and year, etc. If you use DateTimes you can use <,>,<=, and >=

You can try using the Filter Data Table activity. This might work for you, and you can use < to check if it is before the first of the next month and >= of Jan 1 with current year.

For .net solution using the table asenumerable, it would look like this maybe:

datesArray = inputData.AsEnumerable.Where(Function(d) If(IsDate(d(0).ToString.Trim), CDate(d(0).ToString.Trim) < new DateTime(Now.AddMonths(1).Year, Now.AddMonth(1).Month, 1) And CDate(d(0).ToString.Trim) >= new DateTime(Now.Year, 1, 1), False) ).Select(Function(d) CDate(d(0).ToString.Trim) ).ToArray

IF datesArray.Count > 0
    < perform actions on dates >

I used .Select() as shown above to store all the values to a Date array, rather than a DataRow array.

Regards.

I think we can use enumerator constant with number values like enum Month = {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}