With C#.NET you can subtract one DateTime
from another, resulting in a TimeSpan
. For example:
TimeSpan timespan = (DateTime.Now - new DateTime(2011, 1, 1));
If you want a date in between two dates, you can then add half of this timespan to one of the dates:
TimeSpan timespan = (DateTime.Now - new DateTime(2011, 1, 1));
DateTime inBetween = DateTime.Now.AddDays(timespan.TotalDays / 2);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…