in reply to Extract the lines

Where do you have problems? What did you try?

The general approach is simple:

Of course you can optimize due to the knowledge that your lines are sorted, e.g. abort processing once you found a line with a date later than your second one ....

HTH, Rata