Compare Date

I have date column ,I want to get latest near date and time value to Today.
Ex.
7 March
2 February
10 December
25 March.

I want 25 March as it is near or close to todays date.

But their is one additonal case.
Sometime date value will be in time like

2 hours
10 hours.
in above case i need 2 hours value as it is near/close to today time

@TUSHAR_DIWASE

Try the below query.

In Assign activity

datetime_variable = convert.ToDateTime((DT.AsEnumerable.OrderByDescending(function(y) convert.ToDateTime(y("date"))).Where(function(z) convert.ToDateTime(z("date"))<now).FirstOrDefault)("date"))

Example that i have tried.
date
2/14/2019
3/11/2019
10/10/2018
11/2/2019
3/23/2019

Note : Try to parse the date value in the query if you are using other date formats.

thanks for quick response. Sorry but i am new to this,so its hard to understand it.
Sample data.
DateTime(columnName)
11 hours ago
5 hours ago
11 days ago
1 day ago

i need output as 5 hours.
any sample wf

@TUSHAR_DIWASE

can you share some examples of the actual data ? or post the excel file here.

So what you are saying is that you don’t know what format the date column will be in? Like, it could be “11 hours ago, 5 hours ago, 11 days ago” or it could be “7 March, 2 Febrary”

Yeah, provide examples of all variations and maybe someone can come up with something to account for each one example in a single solution.

@ ClaytonM thanks
actually i want to download the latest file image
may be their will be condition that 2 files has time in hours . so i need to click on the file name which is recently modified.
In above case i want to click file name in front of 11 hours ago

i have scrap the data .but i dont know how to proceed

1 Like

Just checking but can you click on “Modified” to sort it by latest date? That would be a simpler way if it sorts it on the page.

1 Like

yes ,it is a way.I am also doing the same but i was wondering is their any way that i can compare date or time with current date or time and get the latest one
Sorry for demanding of this. I just want to explore new ways so that i can learn new ways

“Where there is a will , there is a way

I’m not sure how to convert the “11 hours ago” format, but I can get back to you on that if noone answers you.

thank you so much. I really appreciate it.