Filter Datatable to get only current month Data

Is it possible to filter the data table to get only the current month data.date . For example, Refer to the screenshot above. I just want to get the date for the current month which is 2019-03. Thank you.

Hi @Emma1,

Use below code to filter the data

Dt=dt.select("[date and time] like '2019-03%'").CopyToDataTable()

If you want to dynamically use below code
StrFilter=Now.Year.Tostring()+"-"+Now.Month.ToString()

Dt=dt.select("[date and time] like '"+StrFilter+"%'").CopyToDataTable()

Regards,
Arivu

1 Like

Thank you @arivu96 for your quick response. I will just give it a try.

There is an error. “The source contains no DataRows.” How can that be, my Data table is not empty.

Hi @Emma1,

Can you provide the excel file with those values.

Data.xlsx (35.6 KB)
This is how my excel file. That’s the dummy one. But it looks exactly like this.

Hi @Emma1,

Try below code

StrFilter=Now.Year.Tostring()+"-"+Now.Month.ToString("d2")

Dt=dt.select("[date and time] like '"+StrFilter+"%'").CopyToDataTable()

Regards,
Arivu

1 Like

Hi @Emma1

Refer the below workflow

Sequence.xaml (7.3 KB)

Thank you @anil5. It worked perfectly. I just needed to edit slightly. You really did save my time.:grin::grin:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.