Extract all values between certain time frame in Excel

Hi Everyone,

Beginner to RPA and looking for some help, hope this makes sense.

Looking to build out a report and it works off an extracted CSV file.

Column1 in the CSV has a set string when extracted in the sense of MM\dd\yyyy 6:00 up until the current time when extracted. I need to extract all the rows between MM\dd\yyyyy 6 until MM\dd\yyyyy HH and build it into another datatable. I am able to extract anything that has the current hour at that moment. But i am having trouble doing a between both.

Right now i have For Each loop with an if statement that var.Contains(DateTime.Now.ToString(“MM\dd\yyyy HH”) returns all values that start with the hour. How can i get anything that starts from 6 that current day.

Any help would be greatly appreciated.

  1. For Each Row
  2. varDateTime = Date.ParseExact(Ctype(row(0), String), “MM\dd\yyyy hh:mm”,Nothing)
  3. IF varDateTime.Year = Date.Now.Year AndAlso varDateTime.Month = Date.Now.Month …

Doesn’t look like it works for my process. Basically i am trying to retrieve all rows from 6am until current hour.

for example csv sheet would have this:

06/23/2020 14:02 PM
06/23/2020 14:01 PM
06/23/2020 14:00 PM
06/23/2020 13:59 PM
06/23/2020 13:58 PM
06/23/2020 06:00 AM
06/23/2020 05:59 AM

I need to just add all rows after the 05:59AM row into a new datatable.

Hope that makes sense.

What doesnt work? I just gave you one direction, you need to complete the full IF condition there…

oh! i am sorry about that, didnt realize it went right over my head. Let me try it out then and see how it goes.

Like, after you convert that string to a real datetime variable, will make easier for you to do your condition there…

thanks so much! got it going.

1 Like

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