wyverex Profile Answers by wyverex May 13th, 2008 DateTime t1 = new DateTime(2008, 5, 13); DateTime t2 = new DateTime(2004, 2, 22);TimeSpan span = (t1 > t2 ? t1 - t2 : t2 - t1); Console.WriteLine(span.TotalDays);
dhanu_mitra Profile Answers by dhanu_mitra Dec 31st, 2008 public void DateDiff(){ DateTime startDate = DateTime.Parse("11/12/2008"); DateTime endDate = DateTime.Parse("11/12/2009"); if (endDate > startDate) { TimeSpan span = endDate.Subtract(startDate); Console.WriteLine(span); }}
ngobeseb Profile Answers by ngobeseb Nov 4th, 2009 Here is the better answer:DateTime fDate = DateTime.Now;int thisDay = fDate.DayOfYear; //if today's date is 31/12/2008, thisDay will be 365 and if today's date is 01/01/2009, thisDay will be 1.Therefore, you can use DayOfYear propery to get the day number in a year.
C# Calender Days
Profile Answers by ushalakshmi Questions by ushalakshmi
Questions by ushalakshmi answers by ushalakshmi
Editorial / Best Answer
wyverexProfile Answers by wyverex Questions by wyverex
DateTime t1 = new DateTime(2008, 5, 13);
DateTime t2 = new DateTime(2004, 2, 22);
TimeSpan span = (t1 > t2 ? t1 - t2 : t2 - t1);
Console.WriteLine(span.TotalDays);
Related Answered Questions
Related Open Questions