Filter date from datatable

Hi,
I have stored below details into datatable.

image
In above datatable date is in DD-MM-YYYY format.
Now i have to compare this date with today’s date. I am writing below code but getting errors.

DtTable.Select(“'”+DateTime.ParseExact(DtTable.Rows(“Due Date”),“mm-DD-yyyy”,System.Globalization.CultureInfo.InvariantCulture)+“‘<=’+DateTime.Now.ToLocalTime+'”)

Please help me to resolve this.

@gupta.rak1984 You have two different type of Date Formats present in the Datatable, That might not be good for Processing the Statement you used which takes only one Format, Only Two types of Format are used, or are there more than two?

Only 2

@gupta.rak1984 What should be your result After Comparison ? Do you want to Filter the rows based on Date which are less than or equal to today’s Date ?

Yes date should be less or equal to today’s date

I am unable to understand whats wrong in this code and why its not working

@gupta.rak1984 Have you Checked with this Code :
DtTable.Select(“[Due Date] <= '”+DateTime.Now+'")

Yes tried but no luck , I believe we need to change format of [Due Date]

@gupta.rak1984 Have you tried Filter Datatable Activity?
Considering your Column Value is in Date Format in Excel , It should Work

Hey, @gupta.rak1984

Give this a try:
FilterDate.zip (24.4 KB)
If those are the only two date formats in your datatable, it should work without a hitch. :slight_smile:

1 Like

Thanks a lot @alin.c.mihalea

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