Compare multiple dates in one line of code

Hi all,

I have 5 variabels for which I would like to have a line of code to determine the date that is the most in the future.

Also, to that date I should add 3 days.

Thanks!

  • To add days: Use Datetime1.adddays(1)
  • To add months: Use Datetime1.addmonths(1)
  • To add years: Use Datetime1.addyears(1)

Thanks! Any idea how to get the maximum date out of 5 variables?

Please refer the below link.

https://www.aspforums.net/Threads/827205/How-to-find-Minimum-Min-and-Maximum-Max-dates-from-Generic-List-Array-of-Dates-using-C-Net/

Thanks for your reply but I did not get it and I did it via a workaround.
I wrote my variables in excel and used the MAX function and then re-stored the value as a variable for further calculations :).

1 Like

Hi,

This can be easily achieved using datatable and defaultview property provided datatable column should be of date type.

Check this out:

Thanks,
Nitin

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