Extract data a week from now


I have an excel file with multiple columns, been stuck for a few days trying to gather data from the current date to the end of the week using DateTime.Today < DateTime.Today.AddDays(6) but my use of activities may be flawed as I suck at logic.

The data gathered from the columns must also be aligned with the row name as I am trying to filter out from filtered excel files.

I started with an excel app scope, set ‘devices’ for the read range variable and ‘week’ for another read range variable.
Made another excel app scope, a place for the data to be written in.
Write Range A1 for ‘devices’ followed by an if condition for DateTime.Today < DateTime.Today.AddDays(6).
I left a filter datatable activity in the Then part of the if activity and left the Else blank.
and my bot ends with a write range from the output of the filter datatable.

I’m on Studio Pro and writing with C# any help would be appreciated!

This is a file I just made for reference

Hi @lmoham

Please use the below code for this.


Using this you can build the logic to fetch only the week data. Thanks.

Feel free to reach us at any time if you have doubts.

Happy Automation

Thanks for your response.
I have actually been using that statement however I am not sure how I should go about the activities, could you go through it with me?

Okay, send your xaml file. Thanks.

Do you know when I can send it? Currently restricted as im a new user.


This is all I have so far…

@lmoham - I think…you can transpose the data then easily sort the date column row wise to filter the data…

Let me see, if this works…I will try it and let you know…

@lmoham - Tried the transpose and filtered using the query…

DtTransposed.select().where(Function(row) Date.ParseExact(row(“Item”).tostring,“MM/dd/yyyy hh:mm:ss”,Nothing) < cdate(now.AddDays(6))).CopyToDataTable

Hi thanks for your response!
Is it possible not to transpose but just filter it out?

@lmoham - I will try…

but in the meanwhile please take a look Transpose_Filter.zip (47.9 KB) …

1 Like


I have decided to filter using assign with
weekdata.Select(“DATE1 <= '#” + today+ “#’ AND DATE2 >= '#” + week+ “#'”) in C#
could you tell me how to resolve my problem? I’m not sure if DATE1 and DATE2 are right been trying out various fixes from other forums thks…

Hi @lmoham

Please find the attached xaml file for your reference. Thanks.

FilterDataTableColumns.zip (41.8 KB)

1 Like

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