How to filter dates later than today in the datatable?

Hello, how to filter dates later than today in the datatable? Please step by step, I’m learning how to use datatable, so your tips are a valuable lesson for me. Thank You! :slight_smile:

Hi @sullivanne

→ Use the Read range workbook activity to read the excel and store in a datatable called dt_Input.
→ You can use the LINQ Expression in the assign activity as below,

- Assign -> dt_Output = dt_Input.asenumerable.where(Function(X) CDate(X("Column name").toString) > DateTime.Now).Copytodatatable()

→ Then you can use the Write range workbook activity to write the dt_output to excel.

The filtered data will be stored in dt_Output which the dates are later than today.

Hope it helps!!

1 Like

Hi @sullivanne ,

Step 1: Assign Today’s Date

  1. Add an Assign Activity to store today’s date in a variable.
  • Create a variable named todayDate of type DateTime.
  • In the To field, write todayDate.
  • In the Value field, write DateTime.Now.Date.

Step 2: Filter the DataTable

  1. Add a Filter Data Table Activity to filter rows with dates later than today.
  • Drag the Filter Data Table activity to your sequence.
  • In the Input DataTable field, specify the DataTable you read from read range of workbook in Step 1.
  • In the Output DataTable field, create a new variable to store the filtered DataTable, e.g., filteredDataTable.
  • In the Filter Wizard, set the condition to filter the dates:
    • Select the column with the dates, e.g., DateColumn.
    • Choose the operator > (greater than).
    • In the value field, write todayDate

Regards
Sandy

1 Like

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