Need Help with this logic - Data Time comparisons for a list

I have a use case in which one excel file is modified multiple times and saved with different names. I am able to extract the date time of these files. How do I compare all these dates and times and figure out which one is the latest saved excel.
These are the last modified dates and times.

4/5/2022 1:02 PM
4/5/2022 3:39 PM
4/5/2022 3:28 PM
4/5/2022 1:15 PM

Thanks in advance

Hi @Sairam_RPA

Please check the exact same query which is solved.

I use that for a different scenario. For the current scenario - There are multiple files in that folder. pdf,excel,text,word. There could be multiple excel files that I don’t need as well.

I have filtered out the ones that I need and added them into a list. Now I have to compare and get the latest from the list.

Hi @Sairam_RPA,

You can do it in below format for the excel files.

Directory.GetFiles(yourfolder_path,“*.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)

Its not the file creation time. I have to go by the file modified time.

image

Oh okay sorry I misunderstood. @Sairam_RPA

Check this solution.

@Sairam_RPA,

Check this one as well.

I think this should work. I will try and update you.

Thanks

Sure @Sairam_RPA Take your time!

Hi @shreyash_shirbhate Do you think we have list of date time values. Can we order them in descending. Can you help me do that

these are the values

4/5/2022 1:02 PM
4/5/2022 3:39 PM
4/5/2022 3:28 PM
4/5/2022 1:15 PM

Give it a try @Sairam_RPA

(YourListVariable.OrderBy(Function(n) n).First).ToString

Thanks

Solution

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