Filter dynamic value based on current month from an Excel datatable

Hi,
I have variable values on Excel (ex: 001,002,003,004,005,006,007,008,009,010,011,012). Based on the current month, I need to filter a datatable and delete all the rows with current month.

Can anyone help me?
Many thanks,
Simone

You can use Filter Datatable @simone.de.bortoli


Date.Now.ToString(“MM”) this will return month in integer as ‘08’
Date.Now.ToString(“MMM”) if you use like this it will return month as ‘Aug’

I did this:

where strCurrentMonth is = Now.ToString(“MM”)
I need the Bot to read “007” as final output if July. “010” if October and so on.
Thank you!

I have tried both solutions, yours and mine, none of them are working. Do you know why?

Try adding here
strCurrentMonth is = “0”+Now.ToString(“MM”)

@simone.de.bortoli
Welcome to the forum.

Maybe you can share some sample data / Excel with us. So we can check more individually your case. Thanks

Thank you!
Here is the datatable to filter:

I want to remove the entire set of rows with current year and current month. The current month comes in this format: "001, 002,004, …, 010,011,012).

Thank you!
Simone

Thank you @Sudharsan_Ka! Unfortunately is not working even like that

Just checking is the variable for your year in the format of yyyy?
Also make sure there aren’t any spaces in the column names, that can sometimes be hard to see.

Following flow is doint the filtering:

adopt ColNamesOrIndex and your other VarNames:

(From d In YourDataTableVar.AsEnumerable
Let m = Now.toString(“MM”).PadLeft(3,"0"c)
Let y = Now.ToString(“yyyy”)
Where Not (d(“Fiscal Year”).toString.Trim.Equals(y) And d(“Period”).toString.Trim.Equals(m))
Select d).toList

Variables:
grafik

Similar we can do in Filter Datatable Activity (when excel Values are not having spaces e.g on begin or end)
grafik

Try this @simone.de.bortoli
Date.Now.ToString(“dd/”+“0”+“MM/yyyy”)

Thank you so much

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