I would like to get the total number of days in a year left from the given date .. Assume if a user gives
Let's say the date is today:
var user = "05-08-2012"; var date = DateTime.ParseExact(user, "MM-dd-yyyy", System.Globalization.CultureInfo.InvariantCulture); var lastdate = new DateTime(date.Year, 12, 31); var diff = lastdate - date;
diff.TotalDays contains the number of days (thanks @Tung).
lastdate also contains the last date for the year.