I need to filter date column in a excel.I used filter data table it is not working

I have attached the sample file . I have to filter “LastUpdated” column in excel file . I need to keep only empty row values and date values which is greater than or equal to yesterday date.
FInal.xlsx (9.5 KB)

Hi @sathish_moorthy
You can achieve is by using filter activity

Click on configure filter then add these 2 conditions one for date & other for blanks

Hope this helps :slight_smile:

1 Like

Not working. It is returning empty row values.

Select the Or in advanced filter. This is the expected result right

yes this is the excepted result.

It is working for me. It should work for you as well. Share the screenshot of the configuration

Thanks buddy. Its working

1 Like

@sathish_moorthy @AJ_Ask How this is correct answer?

You are comparing & Filtering with Date as String?
For now it is giving expected output but later on it is wrong!

Regards,
Ajay Mishra

@Ajay_Mishra

True. oversight from my side. Rush to ans. :sweat_smile:

Please find attached the revised code where i use VBA for filtering the data

Sub FilterLastUpdatedColumn()
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim yesterday As Date
    
    yesterday = Date - 1
    
    Set ws = ThisWorkbook.Sheets("Sheet1")
    
    With ws
        lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
        .AutoFilterMode = False
        With .Range("G1:G" & lastRow)
            .AutoFilter Field:=1, Criteria1:="=", Operator:=xlOr, Criteria2:=">=" & Format(yesterday, "mm/dd/yyyy")
        End With
    End With
End Sub

FilterExcel.zip (11.4 KB)

yes. I was having the same doubt but it gave the excepted output at that time. can you provide a solution.

@sathish_moorthy Yes Sure!

Here it is,

Use Assign Activity:

dt_InputFile = dt_InputFile.AsEnumerable().Where(Function(x) String.IsNullOrEmpty(x("LastUpdated").ToString.Trim) OrElse CDate(DateTime.ParseExact(x("LastUpdated").ToString,{"MM/dd/yyyy","MM/dd/yy"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("MM/dd/yyyy"))>=Now.AddDays(-1)).CopyToDataTable

Screenshot for your reference:

Note: I have surround it with Try Catch, If No datarow found then in catch block:

dt_InputFile = dt_InputFile.Clone

Screenshot for your reference:

Workflow Screenshot:

Regards,
Ajay Mishra

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