Filter column in a Datatable using date

Hello,

I have a problem to filter a data table using a sequence of filters. I have a data table from Excel, I need to filter “Echéance” by date equal to September.

is filter datatable sequence solve all my problem? or other sequence/code?

Thankyou

@Ahmed_BEN_JEMIA1

Welcome to the forums

Can you check below thread for your reference

Hope this may help you

Thanks

No, that’s not really what I’m looking for :relieved:.

You’d have to create a new column “Month” then For Each through the datatable and Assign Month based on the value in Echeance. Then you can use Filter Datatable to filter on the Month column.

Thanks for your feedback. How do I assign the month based on the value in Echeance?

Hello,

Will it always come in this format- dd/MM ?
If yes, in filter datatable can you try to give the condition as if column contains “/11”?

Thanks!
Athira

1 Like

Datetime.Parse(CurrentRow(“Echeance”).ToString + “/2022”).Month.ToString

That’ll give you the month as a digit in string format. This assumes the month is the first two digits, so 01/02 would be January 2.

I tried with this but I got an error: “Assign: The string was not recognized as a valid DateTime.”
I added a Month column and a Month variable of type string.

Hello @athira.somasekharan

yes thank you very much!! it works with this method

1 Like

Glad to help!

1 Like

@athira.somasekharan A little clarification, I’m looking for a function that returns the current month and I add +4 following months.
For example, this month May so it returns September.

Hello,

In that case, assign this in a variable:
str_Month=DateTime.Now.AddMonths(4).ToString(“MM”)

And in if condition condition use this: if column contains “/”+ str_Month

Hope this helps!

Hello @athira.somasekharan ,
It works when I add this function in the filter :
Datetime.Now.AddMonths(4).Tostring(“/MM”)

1 Like

What value was it trying to parse when you got that error? Are your dates MM/DD?

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