Last post Oct 27, 2016 07:12 AM by Mikesdotnetting
Oct 27, 2016 05:14 AM|vickyt5|LINK
I have a string and say for ex: 30-10-2016 in a string. Now how can I compare this date with today's date only and find the difference. I am unable to use TimeSpan too because I 'm unable to get date only using datetime. Todays date would be 27-10-2016.
I need to find the difference between these two dates 30-10-2016 - 27-10-2016.
Oct 27, 2016 07:12 AM|Mikesdotnetting|LINK
The following will get the number of days difference between today and the 30th of October:
var input = "30-10-2016";
var date = DateTime.ParseExact(input, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);
var result = (date - DateTime.Now.Date).Days;