Fetch 2 Days After Data Irrspective of the date Gap

I have 3 Scenarios

image

So suppose If today is 7th June i want the bot to display the data of 2 days ahead irrespective of the date gap

Like the Bot on 7th June

if 8th and 9th is present it should print that data

if 9th is not present and 8th and 10th is present it should show 8th and 10th data

if 8th and 9th is not present it should show 10th and 11 data

now.adddays(+1).Tostring(“dateformat”) this will give you the next date

i am considering the data is stored in a datatable dt
create a date_iter variable of type (datetime)

dt_clone=dt.clone()
assign date_iter=Now.date
while (dt_clone.rows.count<2):
     assign list_rows=New List(Of Datarows)
     assign date_iter=date_iter.adddays(1).date
     list_rows=dtasenumerable.where(Function(x) 
     Convert.ToDateTime(x("Date").tostring).equals(date_iter)).tolist
     if list_rows.count>0:
            (add data row) to dt_clone , add the list_rows first value (0)

Try this

how do you know if data is present or not? @Ishan_Shelke1

Currently Now that is not my concern, I just need the data of 2 days ahead from the current date irrespective of the date gap

A Simpler Example

image

Say I have these 4 Scenarios

Now here In the First Scenario The dates are 7th, 8th and 9th So When I Run the Bot on 7th June it should print the date 8th and 9th

In the Second Scenario The dates are 7th, 8th, 10th So When I run the bot on 7th June It should print the date 8th and 10th June because 9th is not available and I need to print 2 ahead dates

Same in the third scenario as you can see 8th and 9th isn’t available So it should jump ahead and capture the dates 10th and 11th

And lastly Same as in fourth Scenario 8th and 9th and 11th dates aren’t available so it will search for 2 dates ahead so it will capture 10th and 12

So basically I need to capture the two immediate dates from the current date

I hope you got my point Thanks.

try this
Main (1).xaml (12.7 KB)

A Simpler Example

image

Say I have these 4 Scenarios

Now here In the First Scenario The dates are 7th, 8th and 9th So When I Run the Bot on 7th June it should print the date 8th and 9th

In the Second Scenario The dates are 7th, 8th, 10th So When I run the bot on 7th June It should print the date 8th and 10th June because 9th is not available and I need to print 2 ahead dates

Same in the third scenario as you can see 8th and 9th isn’t available So it should jump ahead and capture the dates 10th and 11th

And lastly Same as in fourth Scenario 8th and 9th and 11th dates aren’t available so it will search for 2 dates ahead so it will capture 10th and 12

So basically I need to capture the two immediate dates from the current date

I hope you got my point Thanks.

Some un-representable Date time error

image

whats your datetime string value?..

DateTime String Value Is Default I Haven’t Given It Any Value. I Just Ran This Workflow Of Yours. And It Gave This Error

its just a template sorry, cant run by itself

heres how you use the template. @Ishan_Shelke1
test.xlsx (9.4 KB)
Main (1).xaml (16.1 KB)

example excel with dates list
image

if today is 7th june, it will look for 8th JUNE, and so on, if it cant find the date in excel it will look for the next date

after it finds 2 dates, it will end
image

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