Finding closest date from a list of dates comparing to DateTime.Now

I am trying get the closest date from a list of DateTime . I want to compare the DateTime item present in the list to DateTime.Now and get the closest date .

So far I tried: DateTime.Compare(item, DateTime.Now) but this doesn’t work in UiPath as I am unable to find Just DATE type in the UiPath.

hi!. What does it mean “this doesn’t work in UiPath”?
Firstly, you must be imported “System” namespace, and then “DateTime” class will be available.
indent preformatted text by 4 spaces

 DateTime firstDateTime = DateTime.Now;
 DateTime secondDateTime = firstDateTime.AddDays(2);
 int result  = DateTime.Compare(secondDateTime ,firstDateTime);

Have a look here: