开发者

FInd out how many days in the future a datetime is

I have this DateTime object:

开发者_运维问答
model.Model.Results.FloatingComponent().Schedule.ScheduleRows[0].Payment.FromDate.AdjustedDate

How do I find out how many days into the future that is, if it is in the future?


TimeSpan delta = Foo.AdjustedDate - DateTime.Now;

if(delta.Days > 0)
{
  //...
}

Edit:

Based on @Gabe's comment here a version that only looks at the days:

TimeSpan delta = Foo.AdjustedDate.Date - DateTime.Today;

if(delta.Days > 0)
{
  //...
}


DateTime mydate = ....

TimeSpan span = mydate.Subtract(DateTime.Now);

// then use span.Days;


int days = (futureDate - DateTime.Today).Days;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜